Initial refactoring

This commit is contained in:
Erwin Boskma 2023-10-14 16:55:13 +02:00
parent a45809b720
commit e038c2dd15
Signed by: erwin
SSH key fingerprint: SHA256:3F6Cm6I3erRqlBwEghZWAQl6eS5WrGTX1Vs/Evec1lQ
2 changed files with 76 additions and 57 deletions

View file

@ -130,68 +130,12 @@
outputs = outputs =
{ self { self
, sops , sops
, ha-now-playing
, pamedia
, nixinate , nixinate
, flake-parts , flake-parts
, ... , ...
} @ inputs: } @ inputs:
with inputs; let with inputs; let
machines = import ./machines inputs; machines = import ./machines inputs;
defSystem = system: baseConfig: deployConfig:
nixpkgs.lib.nixosSystem {
system = "${system}";
modules = [
{ _module.args.inputs = inputs; }
{ _module.args.self-overlay = self.overlays.default; }
({ ... }: {
imports =
builtins.attrValues self.nixosModules
++ [
{
nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
nixpkgs =
{
overlays = [
self.overlays.default
ha-now-playing.overlays.${system}
pamedia.overlays.${system}
emacs-overlay.overlay
nil.overlays.default
inputs.eww.overlays.default
inputs.rust-overlay.overlays.default
] ++ nixpkgs.lib.optional (system == "aarch64-linux")
(_final: super: {
makeModulesClosure = x:
super.makeModulesClosure (x // { allowMissing = true; });
});
config = {
allowUnfree = true;
firefox.speechSynthesisSupport = true;
};
};
}
baseConfig
home-manager.nixosModules.home-manager
{
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
};
}
];
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
nix.registry.nixpkgs.flake = nixpkgs;
})
sops.nixosModules.sops
sunshine.nixosModules.sunshine
] ++ (nixpkgs.lib.optional (deployConfig != null) { _module.args.nixinate = deployConfig; })
;
};
in in
flake-parts.lib.mkFlake { inherit inputs; } { flake-parts.lib.mkFlake { inherit inputs; } {
@ -201,6 +145,7 @@
]; ];
flake = { flake = {
lib = import ./lib inputs;
overlays.default = import ./overlays; overlays.default = import ./overlays;
@ -214,7 +159,7 @@
nixosConfigurations = builtins.listToAttrs (map nixosConfigurations = builtins.listToAttrs (map
(machine: { (machine: {
name = machine; name = machine;
value = defSystem (machines.${machine}.system or "x86_64-linux") value = self.lib.defSystem (machines.${machine}.system or "x86_64-linux")
{ {
imports = [ imports = [
machines.${machine}.config machines.${machine}.config
@ -226,6 +171,28 @@
apps = nixinate.nixinate.x86_64-linux self; apps = nixinate.nixinate.x86_64-linux self;
colmena = {
meta = {
nixpkgs = import nixpkgs { system = "x86_64-linux"; };
specialArgs = {
inherit nixpkgs;
};
};
drone = { lib, ... }: {
deployment = {
targetHost = "10.0.0.202";
targetUser = "root";
};
imports =
let
system = "x86_64-linux";
systemConfig = import ./machines/drone/configuration.nix inputs;
in
self.lib.systemModules system systemConfig;
};
};
}; };
perSystem = { self', pkgs, system, lib, ... }: perSystem = { self', pkgs, system, lib, ... }:

52
lib/default.nix Normal file
View file

@ -0,0 +1,52 @@
{ self, nixpkgs, ... }@inputs:
rec {
defSystem = system: systemConfig: deployConfig:
nixpkgs.lib.nixosSystem {
system = "${system}";
modules = (systemModules system systemConfig) ++ (nixpkgs.lib.optional (deployConfig != null) { _module.args.nixinate = deployConfig; });
};
systemModules = system: systemConfig:
builtins.attrValues self.nixosModules ++ [
{ _module.args.inputs = inputs; }
{ _module.args.self-overlay = self.overlays.default; }
{
nix.nixPath = [ "nixpkgs=${nixpkgs}" ];
nixpkgs =
{
overlays = [
self.overlays.default
inputs.ha-now-playing.overlays.${system}
inputs.pamedia.overlays.${system}
inputs.emacs-overlay.overlay
inputs.nil.overlays.default
inputs.eww.overlays.default
inputs.rust-overlay.overlays.default
] ++ nixpkgs.lib.optional (system == "aarch64-linux")
(_final: super: {
makeModulesClosure = x:
super.makeModulesClosure (x // { allowMissing = true; });
});
config = {
allowUnfree = true;
firefox.speechSynthesisSupport = true;
};
};
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
};
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
nix.registry.nixpkgs.flake = nixpkgs;
}
systemConfig
inputs.home-manager.nixosModules.home-manager
inputs.sops.nixosModules.sops
inputs.sunshine.nixosModules.sunshine
];
}