Out of curiousity – I know I can build an sdImage like this:
# nix build \
--include nixos-config=./sd-image.nix \
--argstr system aarch64-linux \
--file '<nixpkgs/nixos>' \
--show-trace \
config.system.build.sdImage
– is there any way for me to do the same with flakes “style” from the CLI, without having to write a new flake.nix
?
For example nixosSystem looked promising, but it doesn’t seem like there is any way to pass in args.modules
:
# nix build --dry-run nixpkgs#lib.nixosSystem
error: flake output attribute 'lib.nixosSystem' is not a derivation
I was also trying a number of things like nixpkgs#nixosModules
, or seeing that nixpkgs#legacyPackages.aarch64-linux.config
exists:
# nix repl
nix-repl> :lf nixpkgs
nix-repl> :p legacyPackages.aarch64-linux.config
{ allowAliases = true; allowBroken = false; allowUnfree = false; allowUnsupportedSystem = false; contentAddressedByDefault = false; doCheckByDefault = false; enableParallelBuildingByDefault = false; showDerivationWarnings = [ ]; strictDepsByDefault = false; warnings = [ ]; }
and noting that config
seemed like the base of config.system.build.sdImage
, I tried:
# nix build --dry-run \
nixpkgs#legacyPackages.aarch64-linux.config.system.build.sdImage
error: flake 'flake:nixpkgs' does not provide attribute 'packages.aarch64-linux.legacyPackages.aarch64-linux.config.system.build.sdImage', 'legacyPackages.aarch64-linux.legacyPackages.aarch64-linux.config.system.build.sdImage' or 'legacyPackages.aarch64-linux.config.system.build.sdImage'
- An approach requiring a
flake.nix
: Headless Raspberry pi setup - #4 by amaproblem - Similar: Custom live media with Nix flakes
Issues about not being able to pass args to flakes (which I think is what’s missing – specifically args.modules
, right?):