diff --git a/flake.nix b/flake.nix index 4e04333..5284bed 100644 --- a/flake.nix +++ b/flake.nix @@ -65,13 +65,20 @@ outputs = { self, nixpkgs, home-manager, nixos-hardware , simple-nixos-mailserver, nixgl, flake-utils, treefmt-nix, nixinate , sops-nix, lix-module, ... }: - flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system: + let + lib = nixpkgs.lib.extend (import ./lib); + overlays = [ + (nixpkgs.lib.composeManyExtensions + [ (import ./pkgs/build-support.nix) ]) + (_: super: import ./pkgs super) + (_: super: { + vimPlugins = super.vimPlugins + // (import ./pkgs/vim-plugins.nix super); + }) + ]; + in (flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system: let - pkgs = import nixpkgs { - inherit system; - overlays = [ (import ./lib) ]; - }; - inherit (pkgs) lib; + pkgs = import nixpkgs { inherit lib overlays system; }; inherit (flake-utils.lib) mkApp; treefmt = treefmt-nix.lib.evalModule pkgs { @@ -146,15 +153,7 @@ }; packages = (import ./pkgs) null pkgs; - }) // (let - overlays = [ - (nixpkgs.lib.composeManyExtensions [ (import ./lib) ]) - (import ./pkgs) - (self: super: { - vimPlugins = super.vimPlugins - // (import ./pkgs/vim-plugins.nix self super); - }) - ]; + })) // (let machines = { back = { }; fort = { }; @@ -163,10 +162,12 @@ [ nixos-hardware.nixosModules.framework-12th-gen-intel ]; zero = { }; }; + mkSystem = name: { extraModules ? [ ], system ? "x86_64-linux" }: nixpkgs.lib.nixosSystem { inherit system; + specialArgs = { inherit lib; }; modules = [ sops-nix.nixosModules.sops simple-nixos-mailserver.nixosModules.mailserver diff --git a/lib/default.nix b/lib/default.nix index a468fe6..864e26f 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,31 +1,3 @@ -_: -{ lib, writeTextFile, perl, perlPackages, ... }: +_: _: -{ - c8h4.buildPerlApplication = { name, text, perlInputs ? (_: [ ]) - , runtimeInputs ? [ ], derivationArgs ? { } }: - writeTextFile { - inherit name derivationArgs; - executable = true; - destination = "/bin/${name}"; - - checkPhase = '' - runHook preCheck - ${lib.getExe perlPackages.PerlCritic} $target - runHook postCheck - ''; - - text = '' - #!${lib.getExe (perl.withPackages perlInputs)} - - use strict; - use warnings; - - $ENV{PATH} = "${lib.makeBinPath runtimeInputs}:$ENV{PATH}"; - - ${text} - ''; - - meta.mainProgram = name; - }; -} +{ } diff --git a/pkgs/build-support.nix b/pkgs/build-support.nix new file mode 100644 index 0000000..fdaab17 --- /dev/null +++ b/pkgs/build-support.nix @@ -0,0 +1,31 @@ +_: +{ lib, perl, perlPackages, writeTextFile, ... }: + +{ + c8h4.buildPerlApplication = { name, text, perlInputs ? (_: [ ]) + , runtimeInputs ? [ ], derivationArgs ? { } }: + writeTextFile { + inherit name derivationArgs; + executable = true; + destination = "/bin/${name}"; + + checkPhase = '' + runHook preCheck + ${lib.getExe perlPackages.PerlCritic} $target + runHook postCheck + ''; + + text = '' + #!${lib.getExe (perl.withPackages perlInputs)} + + use strict; + use warnings; + + $ENV{PATH} = "${lib.makeBinPath runtimeInputs}:$ENV{PATH}"; + + ${text} + ''; + + meta.mainProgram = name; + }; +}