Skip to content

Instantly share code, notes, and snippets.

@JohnRTitor
Last active July 12, 2024 15:45
Show Gist options
  • Save JohnRTitor/4cfdc99c853f5a82e4f8ac5e3679fd7e to your computer and use it in GitHub Desktop.
Save JohnRTitor/4cfdc99c853f5a82e4f8ac5e3679fd7e to your computer and use it in GitHub Desktop.
Nix Tips and Tricks

Build normal packages - x64

nix build .#hello

Build 32 bit packages - x86

nix build .#pkgsi686Linux.hello

Cross compile aarch64-linux binaries on x64-linux

nom build .#legacyPackages.x86_64-linux.pkgsCross.aarch64-multiplatform.hello

Nix run/build with override

nix run --impure --expr '(builtins.getFlake "github:nixos/nixpkgs/nixpkgs-unstable").legacyPackages."${builtins.currentSystem}".discord.override {withVencord = true;}'
@JohnRTitor
Copy link
Author

JohnRTitor commented Jun 21, 2024

Disable pushing to a upstream repo where you have write access

git remote set-url upstream --push no_push

@JohnRTitor
Copy link
Author

Run package-internal tests with nix-build --attr pkgs.PACKAGE.passthru.tests
Run NixOS tests with nix-build --attr nixosTests.NAME, where NAME is the name of the test listed in nixos/tests/all-tests.nix
Run global package tests with nix-build --attr tests.PACKAGE, where PACKAGE is the name of the test listed in pkgs/test/default.nix

@JohnRTitor
Copy link
Author

From github.com:NixOS/nixpkgs

  • [new ref] refs/pull/298081/head -> jetbrains-plugin-magento-phpstorm
    Updating files: 100% (26143/26143), done.
    Switched to branch 'jetbrains-plugin-magento-phpstorm'

@JohnRTitor
Copy link
Author

Build NixOS manual for NixOS module PRs:

nix build github:nixos/nixpkgs/refs/pull/322591/merge#htmlDocs.nixosManual.x86_64-linux --print-out-paths

@JohnRTitor
Copy link
Author

JohnRTitor commented Jul 2, 2024

Simple nix repl evaluation check

nix repl --expr 'import <nixpkgs>{}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment