Skip to content

Commit

Permalink
switch to withSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
devusb committed Feb 23, 2024
1 parent fc9bbe8 commit e29b9f0
Showing 1 changed file with 38 additions and 55 deletions.
93 changes: 38 additions & 55 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
./modules/nomad-client.nix
];
in
flake-parts.lib.mkFlake { inherit inputs; } {
flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, ... }: {
imports = [
hercules-ci-effects.flakeModule
hercules-ci-effects.push-cache-effect
Expand All @@ -76,128 +76,111 @@
nvidia.acceptLicense = true;
};
};
_module.args.pkgs = legacyPackages;

formatter = legacyPackages.nixpkgs-fmt;
};

flake = with self; {
flake = {
images = {
sophia = nixos-generators.nixosGenerate {
sophia = withSystem "aarch64-linux" ({ pkgs, ... }: nixos-generators.nixosGenerate {
inherit pkgs;
modules = defaultImports ++ [
./hosts/sophia
];
pkgs = legacyPackages."aarch64-linux";
format = "sd-aarch64-installer";
};
});
blocky-fly =
let
system = "x86_64-linux";
pkgs = legacyPackages.${system};
in
blocky-tailscale.packages.${system}.blocky-tailscale.override {
withSystem "x86_64-linux" ({ pkgs, system, ... }: blocky-tailscale.packages.${system}.blocky-tailscale.override {
blockyConfig = pkgs.writeText "blocky.conf" (builtins.toJSON (import ./images/blocky-fly/blocky-config.nix { }));
};
gaia = nixos-generators.nixosGenerate {
});
gaia = withSystem "aarch64-linux" ({ pkgs, ... }: nixos-generators.nixosGenerate {
inherit pkgs;
modules = defaultImports ++ [
./hosts/gaia
];
specialArgs = { inherit inputs; };
pkgs = legacyPackages."aarch64-linux";
format = "sd-aarch64-installer";
};
pomerium =
let
system = "x86_64-linux";
pkgs = legacyPackages.${system};
in
pkgs.dockerTools.buildLayeredImage (import ./images/pomerium pkgs);
});
pomerium = withSystem "x86_64-linux" ({ pkgs, ... }: pkgs.dockerTools.buildLayeredImage (import ./images/pomerium pkgs));
};

nixosConfigurations = {
sophia =
let system = "aarch64-linux";
in
nixpkgs.lib.nixosSystem {
pkgs = legacyPackages."${system}";
withSystem "aarch64-linux" ({ pkgs, system, ... }: nixpkgs.lib.nixosSystem {
inherit pkgs;
extraModules = [ colmena.nixosModules.deploymentOptions ];
modules = defaultImports ++ [
{ nixpkgs.system = system; } # needed to use aarch64-linux packages
./hosts/sophia
./hosts/sophia/colmena.nix
];
};
});

chopper =
let system = "x86_64-linux";
in
nixpkgs.lib.nixosSystem {
pkgs = legacyPackages."${system}";
withSystem "x86_64-linux" ({ pkgs, ... }: nixpkgs.lib.nixosSystem {
inherit pkgs;
specialArgs = { inherit inputs; };
extraModules = [ colmena.nixosModules.deploymentOptions ];
modules = defaultImports ++ [
./hosts/chopper
./hosts/chopper/colmena.nix
];
};
});

gaia0 =
let system = "aarch64-linux";
in
nixpkgs.lib.nixosSystem {
pkgs = legacyPackages."${system}";
withSystem "aarch64-linux" ({ pkgs, system, ... }: nixpkgs.lib.nixosSystem {
inherit pkgs;
specialArgs = { inherit inputs; };
extraModules = [ colmena.nixosModules.deploymentOptions ];
modules = defaultImports ++ [
{ nixpkgs.system = system; }
./hosts/gaia
./hosts/gaia/gaia0.nix
];
};
});

gaia1 =
let system = "aarch64-linux";
in
nixpkgs.lib.nixosSystem {
pkgs = legacyPackages."${system}";
withSystem "aarch64-linux" ({ pkgs, system, ... }: nixpkgs.lib.nixosSystem {
inherit pkgs;
specialArgs = { inherit inputs; };
extraModules = [ colmena.nixosModules.deploymentOptions ];
modules = defaultImports ++ [
{ nixpkgs.system = system; }
./hosts/gaia
./hosts/gaia/gaia1.nix
];
};
});

spdr =
let system = "x86_64-linux";
in
nixpkgs.lib.nixosSystem {
pkgs = legacyPackages."${system}";
withSystem "x86_64-linux" ({ pkgs, ... }: nixpkgs.lib.nixosSystem {
inherit pkgs;
extraModules = [ colmena.nixosModules.deploymentOptions ];
modules = defaultImports ++ [
./hosts/spdr
];
};
});
};

colmena =
let conf = self.nixosConfigurations;
in
{
meta = {
nixpkgs = legacyPackages."x86_64-linux";
nodeSpecialArgs = builtins.mapAttrs (name: value: value._module.specialArgs) conf;
};
} // builtins.mapAttrs (name: value: { imports = value._module.args.modules; }) conf;
withSystem "x86_64-linux"
({ pkgs, ... }: {
meta = {
nixpkgs = pkgs;
nodeSpecialArgs = builtins.mapAttrs (name: value: value._module.specialArgs) conf;
};
}) // builtins.mapAttrs (name: value: { imports = value._module.args.modules; }) conf;

checks."x86_64-linux" = {
sophia = nixpkgs.lib.nixos.runTest {
sophia = withSystem "x86_64-linux" ({ pkgs, ... }: nixpkgs.lib.nixos.runTest {
imports = [
./hosts/sophia/tests.nix
];
hostPkgs = legacyPackages."x86_64-linux";
hostPkgs = pkgs;
node.specialArgs = { inherit inputs; };
};
});
};
};

Expand All @@ -220,8 +203,8 @@
packages = map (host: self.nixosConfigurations."${host}".config.system.build.toplevel) (builtins.attrNames self.nixosConfigurations);
};
};
});

};
}


0 comments on commit e29b9f0

Please sign in to comment.