From ce4bda88621d5322704ec6a68af6e23a4916c00e Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 19 Mar 2021 22:11:25 +0100 Subject: [PATCH] nix/pkgs/default: init, add export-config --- flake.nix | 13 +++---------- nix/pkgs/default.nix | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 nix/pkgs/default.nix diff --git a/flake.nix b/flake.nix index a7edbdf..a9272ee 100644 --- a/flake.nix +++ b/flake.nix @@ -15,16 +15,9 @@ lib = import ./nix/lib { inherit nixpkgs; }; - packages = forAllSystems (system: { - test_vm = nixpkgs.legacyPackages.${system}.runCommandLocal "test_vm" { - src = nixosConfigurations.test_vm.config.system.build.toplevel; - } '' - set -x - mkdir -p $out/{bin,dev,etc,home,mnt,nix/store,nix/var,proc,root,run,sys,tmp,var,usr} - ln -s $src/init $out/ - ln -s $src/etc $out/etc/static - ''; - } // (import ./nix/pkgs/device-templates.nix { inherit self nixpkgs system; })); + packages = forAllSystems (system: + import ./nix/pkgs { inherit self nixpkgs system; } + ); nixosModule = { ... }: { imports = nixpkgs.lib.filesystem.listFilesRecursive ./nix/nixos-modules; diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix new file mode 100644 index 000000000..e90070e --- /dev/null +++ b/nix/pkgs/default.nix @@ -0,0 +1,30 @@ +{ self, nixpkgs, system }: + +let + inherit (self.lib) config; + + export-config-file = builtins.toFile "config.nix" ( + nixpkgs.lib.generators.toPretty {} config + ); + # Debug dump aid + export-config = nixpkgs.legacyPackages.${system}.runCommandLocal "config.nix" {} '' + cp ${export-config-file} $out + ''; + + test_vm = nixpkgs.legacyPackages.${system}.runCommandLocal "test_vm" { + src = self.nixosConfigurations.test_vm.config.system.build.toplevel; + } '' + set -x + mkdir -p $out/{bin,dev,etc,home,mnt,nix/store,nix/var,proc,root,run,sys,tmp,var,usr} + ln -s $src/init $out/ + ln -s $src/etc $out/etc/static + ''; + + device-templates = import ./device-templates.nix { + inherit self nixpkgs system; + }; + +in +device-templates // { + inherit export-config test_vm; +}