Improve apps and devShell

This commit is contained in:
Jack O'Sullivan 2022-02-13 14:28:49 +00:00
parent 0905611700
commit f6e5f36e69
2 changed files with 36 additions and 21 deletions

View File

@ -30,16 +30,13 @@
nixpkgs-unstable, nixpkgs-stable, nixpkgs-unstable, nixpkgs-stable,
agenix,
deploy-rs,
... ...
}: }:
let let
inherit (builtins) mapAttrs; inherit (builtins) mapAttrs;
inherit (lib) genAttrs mapAttrs'; inherit (lib) genAttrs mapAttrs';
inherit (lib.flake) defaultSystems eachDefaultSystem; inherit (lib.flake) defaultSystems eachDefaultSystem;
inherit (lib.my) addPrefix mkApp; inherit (lib.my) addPrefix mkApp mkShellApp;
extendLib = lib: lib.extend (final: prev: { extendLib = lib: lib.extend (final: prev: {
my = import ./util.nix { lib = final; }; my = import ./util.nix { lib = final; };
@ -54,10 +51,20 @@
lib = pkgsFlakes.unstable.lib; lib = pkgsFlakes.unstable.lib;
pkgs' = mapAttrs (_: path: lib.my.mkPkgs path { overlays = [ libOverlay ]; }) pkgsFlakes; pkgs' = mapAttrs
(_: path: lib.my.mkDefaultSystemsPkgs path {
overlays = [
libOverlay
inputs.agenix.overlay
inputs.deploy-rs.overlay
inputs.nix.overlay
];
})
pkgsFlakes;
in in
# Platform independent stuff
{ {
inherit lib; lib = lib.my;
nixosModules = mapAttrs nixosModules = mapAttrs
(_: path: (_: path:
@ -77,19 +84,26 @@
nixosConfigurations = import ./systems.nix { inherit lib pkgsFlakes inputs; modules = self.nixosModules; }; nixosConfigurations = import ./systems.nix { inherit lib pkgsFlakes inputs; modules = self.nixosModules; };
systems = mapAttrs (_: system: system.config.system.build.toplevel) self.nixosConfigurations; systems = mapAttrs (_: system: system.config.system.build.toplevel) self.nixosConfigurations;
vms = mapAttrs (name: system: system.config.my.build.devVM) self.nixosConfigurations; vms = mapAttrs (_: system: system.config.my.build.devVM) self.nixosConfigurations;
} //
(eachDefaultSystem (system:
let
pkgs = pkgs'.unstable.${system};
lib = pkgs.lib;
in
# Stuff for each platform
{
apps = {
fmt = mkShellApp pkgs "fmt" ''exec "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" "$@" .'';
};
devShell = genAttrs defaultSystems (system: devShell = pkgs.mkShell {
let packages = with pkgs; [
pkgs = pkgs'.unstable.${system}; nix
flakePkg = f: f.defaultPackage.${system}; agenix
in deploy-rs.deploy-rs
pkgs.mkShell { nixpkgs-fmt
packages = map flakePkg [ ];
agenix };
deploy-rs }));
];
}
);
};
} }

View File

@ -21,8 +21,9 @@ rec {
ports = checked (replaceStrings ["-"] [":"] (elemAt m 1)); ports = checked (replaceStrings ["-"] [":"] (elemAt m 1));
}; };
mkPkgs = path: args: genAttrs defaultSystems (system: import path (args // { inherit system; })); mkDefaultSystemsPkgs = path: args: genAttrs defaultSystems (system: import path (args // { inherit system; }));
mkApp = program: { type = "app"; inherit program; }; mkApp = program: { type = "app"; inherit program; };
mkShellApp = pkgs: name: text: mkApp (pkgs.writeShellScript name text).outPath;
mkOpt = type: default: mkOption { inherit type default; }; mkOpt = type: default: mkOption { inherit type default; };
mkBoolOpt = default: mkOption { mkBoolOpt = default: mkOption {