move rootfs nixos-module to nix/pkgs
This commit is contained in:
parent
d1cca3b029
commit
681ac0ab5d
|
@ -43,14 +43,5 @@
|
|||
builtins.elem role [ "server" "container" ]
|
||||
) self.lib.config.site.hosts
|
||||
);
|
||||
|
||||
# nixosConfigurations.test_vm =
|
||||
# nixpkgs.lib.nixosSystem {
|
||||
# inherit system;
|
||||
# modules = [ nixosModule ];
|
||||
# extraModules = [ ({ ... }: {
|
||||
# networking.hostName = "test_vm";
|
||||
# }) ];
|
||||
# };
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,15 +16,6 @@ let
|
|||
);
|
||||
enabled = containers != {};
|
||||
|
||||
mkRootfs = ctName:
|
||||
pkgs.runCommandLocal "rootfs_${ctName}" {
|
||||
src = self.nixosConfigurations.${ctName}.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
|
||||
'';
|
||||
in
|
||||
{
|
||||
virtualisation.lxc = lib.mkIf enabled {
|
||||
|
@ -42,7 +33,7 @@ in
|
|||
environment.etc =
|
||||
builtins.foldl' (etc: ctName: etc // {
|
||||
"lxc/containers/${ctName}/rootfs" = {
|
||||
source = mkRootfs ctName;
|
||||
source = self.packages.x86_64-linux."${ctName}-rootfs";
|
||||
};
|
||||
"lxc/containers/${ctName}/config" = {
|
||||
enable = true;
|
||||
|
|
|
@ -23,20 +23,31 @@ let
|
|||
) (builtins.attrNames config.site.hosts)
|
||||
);
|
||||
|
||||
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
|
||||
'';
|
||||
mkRootfs = hostName:
|
||||
nixpkgs.legacyPackages.${system}.runCommandLocal "rootfs_${hostName}" {
|
||||
src = self.nixosConfigurations.${hostName}.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
|
||||
'';
|
||||
|
||||
rootfs =
|
||||
builtins.foldl' (rootfs: hostName: rootfs // {
|
||||
"${hostName}-rootfs" = mkRootfs hostName;
|
||||
}) {} (
|
||||
builtins.attrNames (
|
||||
nixpkgs.lib.filterAttrs (_: { role, ... }: role == "container")
|
||||
config.site.hosts
|
||||
)
|
||||
);
|
||||
|
||||
device-templates = import ./device-templates.nix {
|
||||
inherit self nixpkgs system;
|
||||
};
|
||||
|
||||
in
|
||||
salt-pillars // device-templates // {
|
||||
inherit export-config test_vm;
|
||||
salt-pillars // rootfs // device-templates // {
|
||||
inherit export-config;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue