mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 00:57:22 +01:00
feat: add globals system
This commit is contained in:
parent
6cac368378
commit
2aa5e0095c
31 changed files with 833 additions and 528 deletions
280
flake.nix
280
flake.nix
|
|
@ -83,6 +83,7 @@
|
|||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nix-topology.url = "github:oddlama/nix-topology";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
};
|
||||
outputs =
|
||||
inputs@{ self
|
||||
|
|
@ -97,113 +98,192 @@
|
|||
lib = (nixpkgs.lib // home-manager.lib).extend (_: _: { swarselsystems = import ./lib { inherit self lib inputs outputs systems; }; });
|
||||
|
||||
in
|
||||
{
|
||||
inherit lib;
|
||||
|
||||
# nixosModules = import ./modules/nixos { inherit lib; };
|
||||
# homeModules = import ./modules/home { inherit lib; };
|
||||
packages = lib.swarselsystems.forEachSystem (pkgs: import ./pkgs { inherit lib pkgs; });
|
||||
formatter = lib.swarselsystems.forEachSystem (pkgs: pkgs.nixpkgs-fmt);
|
||||
overlays = import ./overlays { inherit self lib inputs; };
|
||||
|
||||
apps = lib.swarselsystems.forAllSystems (system:
|
||||
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
imports = [
|
||||
./nix/globals.nix
|
||||
];
|
||||
flake = { config, ... }:
|
||||
let
|
||||
appNames = [
|
||||
"swarsel-bootstrap"
|
||||
"swarsel-install"
|
||||
"swarsel-rebuild"
|
||||
"swarsel-postinstall"
|
||||
];
|
||||
appSet = lib.swarselsystems.mkApps system appNames self;
|
||||
in
|
||||
|
||||
appSet // {
|
||||
default = appSet.swarsel-bootstrap;
|
||||
}
|
||||
);
|
||||
inherit (self) outputs;
|
||||
lib = (nixpkgs.lib // home-manager.lib).extend (_: _: { swarselsystems = import ./lib { inherit self lib inputs outputs systems; }; });
|
||||
|
||||
|
||||
linuxUser = "swarsel";
|
||||
macUser = "leon.schwarzaeugl";
|
||||
|
||||
mkFullHost = host: type: {
|
||||
${host} =
|
||||
let
|
||||
systemFunc = if (type == "nixos") then lib.nixosSystem else inputs.nix-darwin.lib.darwinSystem;
|
||||
in
|
||||
systemFunc {
|
||||
specialArgs = { inherit inputs outputs lib self; inherit (config) globals; };
|
||||
modules = [
|
||||
{
|
||||
node.name = host;
|
||||
node.secretsDir = ./hosts/${type}/${host}/secrets;
|
||||
}
|
||||
# put inports here that are for all hosts
|
||||
inputs.disko.nixosModules.disko
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
inputs.impermanence.nixosModules.impermanence
|
||||
inputs.lanzaboote.nixosModules.lanzaboote
|
||||
inputs.fw-fanctrl.nixosModules.default
|
||||
"${self}/hosts/${type}/${host}"
|
||||
{
|
||||
_module.args.primaryUser = linuxUser;
|
||||
}
|
||||
] ++
|
||||
(if (host == "iso") then [
|
||||
inputs.nix-topology.nixosModules.default
|
||||
] else
|
||||
([
|
||||
# put nixos imports here that are for all servers and normal hosts
|
||||
inputs.nix-topology.nixosModules.default
|
||||
"${self}/modules/${type}/common"
|
||||
inputs.stylix.nixosModules.stylix
|
||||
inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm
|
||||
] ++ (if (type == "nixos") then [
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
"${self}/profiles/nixos"
|
||||
"${self}/modules/nixos/server"
|
||||
"${self}/modules/nixos/optional"
|
||||
{
|
||||
home-manager.users."${linuxUser}".imports = [
|
||||
# put home-manager imports here that are for all normal hosts
|
||||
"${self}/modules/home/common"
|
||||
"${self}/modules/home/server"
|
||||
"${self}/modules/home/optional"
|
||||
"${self}/profiles/home"
|
||||
];
|
||||
}
|
||||
] else [
|
||||
# put nixos imports here that are for darwin hosts
|
||||
"${self}/modules/darwin/nixos/common"
|
||||
"${self}/profiles/darwin"
|
||||
inputs.home-manager.darwinModules.home-manager
|
||||
{
|
||||
home-manager.users."${macUser}".imports = [
|
||||
# put home-manager imports here that are for darwin hosts
|
||||
"${self}/modules/darwin/home"
|
||||
"${self}/modules/home/server"
|
||||
"${self}/modules/home/optional"
|
||||
"${self}/profiles/home"
|
||||
];
|
||||
}
|
||||
])
|
||||
));
|
||||
};
|
||||
};
|
||||
|
||||
mkHalfHost = host: type: pkgs: {
|
||||
${host} =
|
||||
let
|
||||
systemFunc = if (type == "home") then inputs.home-manager.lib.homeManagerConfiguration else inputs.nix-on-droid.lib.nixOnDroidConfiguration;
|
||||
in
|
||||
systemFunc
|
||||
{
|
||||
inherit pkgs;
|
||||
extraSpecialArgs = { inherit inputs outputs lib self; };
|
||||
modules = [ "${self}/hosts/${type}/${host}" ];
|
||||
};
|
||||
};
|
||||
|
||||
mkFullHostConfigs = hosts: type: lib.foldl (acc: set: acc // set) { } (lib.map (host: mkFullHost host type) hosts);
|
||||
|
||||
mkHalfHostConfigs = hosts: type: pkgs: lib.foldl (acc: set: acc // set) { } (lib.map (host: mkHalfHost host type pkgs) hosts);
|
||||
|
||||
devShells = lib.swarselsystems.forAllSystems (system:
|
||||
let
|
||||
pkgs = lib.swarselsystems.pkgsFor.${system};
|
||||
checks = self.checks.${system};
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
# plugin-files = ${pkgs.nix-plugins.overrideAttrs (o: {
|
||||
# buildInputs = [pkgs.nixVersions.latest pkgs.boost];
|
||||
# patches = (o.patches or []) ++ [ "${self}/nix/nix-plugins.patch" ];
|
||||
# })}/lib/nix/plugins
|
||||
NIX_CONFIG = ''
|
||||
plugin-files = ${pkgs.nix-plugins}/lib/nix/plugins
|
||||
extra-builtins-file = ${self + /nix/extra-builtins.nix}
|
||||
'';
|
||||
inherit (checks.pre-commit-check) shellHook;
|
||||
inherit lib;
|
||||
|
||||
buildInputs = checks.pre-commit-check.enabledPackages;
|
||||
nativeBuildInputs = [
|
||||
(builtins.trace "alarm: we pinned nix_2_24 because of https://github.com/shlevy/nix-plugins/issues/20" pkgs.nixVersions.nix_2_24) # Always use the nix version from this flake's nixpkgs version, so that nix-plugins (below) doesn't fail because of different nix versions.
|
||||
# pkgs.nix
|
||||
pkgs.home-manager
|
||||
pkgs.git
|
||||
pkgs.just
|
||||
pkgs.age
|
||||
pkgs.ssh-to-age
|
||||
pkgs.sops
|
||||
pkgs.statix
|
||||
pkgs.deadnix
|
||||
pkgs.nixpkgs-fmt
|
||||
# nixosModules = import ./modules/nixos { inherit lib; };
|
||||
# homeModules = import ./modules/home { inherit lib; };
|
||||
packages = lib.swarselsystems.forEachSystem (pkgs: import ./pkgs { inherit lib pkgs; });
|
||||
formatter = lib.swarselsystems.forEachSystem (pkgs: pkgs.nixpkgs-fmt);
|
||||
overlays = import ./overlays { inherit self lib inputs; };
|
||||
|
||||
apps = lib.swarselsystems.forAllSystems (system:
|
||||
let
|
||||
appNames = [
|
||||
"swarsel-bootstrap"
|
||||
"swarsel-install"
|
||||
"swarsel-rebuild"
|
||||
"swarsel-postinstall"
|
||||
];
|
||||
appSet = lib.swarselsystems.mkApps system appNames self;
|
||||
in
|
||||
|
||||
appSet // {
|
||||
default = appSet.swarsel-bootstrap;
|
||||
}
|
||||
);
|
||||
|
||||
devShells = lib.swarselsystems.forAllSystems (system:
|
||||
let
|
||||
pkgs = lib.swarselsystems.pkgsFor.${system};
|
||||
checks = self.checks.${system};
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
# plugin-files = ${pkgs.nix-plugins.overrideAttrs (o: {
|
||||
# buildInputs = [pkgs.nixVersions.latest pkgs.boost];
|
||||
# patches = (o.patches or []) ++ [ "${self}/nix/nix-plugins.patch" ];
|
||||
# })}/lib/nix/plugins
|
||||
NIX_CONFIG = ''
|
||||
plugin-files = ${pkgs.nix-plugins}/lib/nix/plugins
|
||||
extra-builtins-file = ${self + /nix/extra-builtins.nix}
|
||||
'';
|
||||
inherit (checks.pre-commit-check) shellHook;
|
||||
|
||||
buildInputs = checks.pre-commit-check.enabledPackages;
|
||||
nativeBuildInputs = [
|
||||
(builtins.trace "alarm: we pinned nix_2_24 because of https://github.com/shlevy/nix-plugins/issues/20" pkgs.nixVersions.nix_2_24) # Always use the nix version from this flake's nixpkgs version, so that nix-plugins (below) doesn't fail because of different nix versions.
|
||||
# pkgs.nix
|
||||
pkgs.home-manager
|
||||
pkgs.git
|
||||
pkgs.just
|
||||
pkgs.age
|
||||
pkgs.ssh-to-age
|
||||
pkgs.sops
|
||||
pkgs.statix
|
||||
pkgs.deadnix
|
||||
pkgs.nixpkgs-fmt
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
templates = import ./templates { inherit lib; };
|
||||
|
||||
checks = lib.swarselsystems.forAllSystems (system:
|
||||
let
|
||||
pkgs = lib.swarselsystems.pkgsFor.${system};
|
||||
in
|
||||
import ./checks { inherit self inputs system pkgs; }
|
||||
);
|
||||
|
||||
diskoConfigurations.default = import .templates/hosts/nixos/disk-config.nix;
|
||||
|
||||
nixosConfigurations = mkFullHostConfigs (lib.swarselsystems.readHosts "nixos") "nixos";
|
||||
homeConfigurations = mkHalfHostConfigs (lib.swarselsystems.readHosts "home") "home" lib.swarselsystems.pkgsFor.x86_64-linux;
|
||||
darwinConfigurations = mkFullHostConfigs (lib.swarselsystems.readHosts "darwin") "darwin";
|
||||
nixOnDroidConfigurations = mkHalfHostConfigs (lib.swarselsystems.readHosts "android") "android" lib.swarselsystems.pkgsFor.aarch64-linux;
|
||||
|
||||
topology = lib.swarselsystems.forEachSystem (pkgs: import inputs.nix-topology {
|
||||
inherit pkgs;
|
||||
modules = [
|
||||
"${self}/topology"
|
||||
{ inherit (self) nixosConfigurations; }
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
templates = import ./templates { inherit lib; };
|
||||
|
||||
checks = lib.swarselsystems.forAllSystems (system:
|
||||
let
|
||||
pkgs = lib.swarselsystems.pkgsFor.${system};
|
||||
in
|
||||
import ./checks { inherit self inputs system pkgs; }
|
||||
);
|
||||
|
||||
diskoConfigurations.default = import .templates/hosts/nixos/disk-config.nix;
|
||||
|
||||
nixosConfigurations =
|
||||
lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "nixos") "nixos";
|
||||
homeConfigurations =
|
||||
|
||||
# "swarsel@home-manager" = inputs.home-manager.lib.homeManagerConfiguration {
|
||||
# pkgs = lib.swarselsystems.pkgsFor.x86_64-linux;
|
||||
# extraSpecialArgs = { inherit inputs outputs; };
|
||||
# modules = homeModules ++ mixedModules ++ [
|
||||
# ./hosts/home-manager
|
||||
# ];
|
||||
# };
|
||||
|
||||
lib.swarselsystems.mkHalfHostConfigs (lib.swarselsystems.readHosts "home") "home" lib.swarselsystems.pkgsFor.x86_64-linux;
|
||||
darwinConfigurations =
|
||||
lib.swarselsystems.mkFullHostConfigs (lib.swarselsystems.readHosts "darwin") "darwin";
|
||||
nixOnDroidConfigurations =
|
||||
|
||||
# magicant = inputs.nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
# pkgs = lib.swarselsystems.pkgsFor.aarch64-linux;
|
||||
# modules = [
|
||||
# ./hosts/magicant
|
||||
# ];
|
||||
# };
|
||||
|
||||
lib.swarselsystems.mkHalfHostConfigs (lib.swarselsystems.readHosts "android") "android" lib.swarselsystems.pkgsFor.aarch64-linux;
|
||||
|
||||
|
||||
topology =
|
||||
|
||||
lib.swarselsystems.forEachSystem (pkgs: import inputs.nix-topology {
|
||||
inherit pkgs;
|
||||
modules = [
|
||||
"${self}/topology"
|
||||
{ inherit (self) nixosConfigurations; }
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
nodes = config.nixosConfigurations;
|
||||
};
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue