From 9865e974f51cfca8ce02d434f7f47fc238fc2d08 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 14 Nov 2022 21:55:46 +0100 Subject: modularize tools --- shell.nix | 32 ++++++-------------------------- tools/ca/default.nix | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 tools/ca/default.nix diff --git a/shell.nix b/shell.nix index 14125d02..5d8e2c5a 100644 --- a/shell.nix +++ b/shell.nix @@ -1,32 +1,13 @@ -{ system, self, deploy-rs, nvfetcher, mach-nix, leapseconds, ... }: +inputs@{ system, self, deploy-rs, nvfetcher, nixpkgs, ... }: let pkgs = self.legacyPackages.${system}; + utils = import ./utils { inherit (nixpkgs) lib; }; + inherit (utils) nixImport; - ca = mach-nix.lib.${system}.buildPythonPackage { - pname = "ca"; - src = ./tools/ca; - version = "0.0.0"; - ignoreDataOutdated = true; - - requirements = '' - cryptography >=38.0.0 - fqdn - atomicwrites - leapseconddata - xkcdpass - ''; - - _.cryptography.buildInputs = with pkgs; [ openssl ]; - - postInstall = '' - wrapProgram $out/bin/ca \ - --set-default LEAPSECONDS_FILE ${leapseconds} \ - --prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [sops])} - ''; - }; + tools = nixImport rec { dir = ./tools; _import = _path: name: import "${toString dir}/${name}" inputs; }; in pkgs.mkShell { name = "nixos"; - nativeBuildInputs = with pkgs; [ + nativeBuildInputs = builtins.attrValues tools ++ (with pkgs; [ sops wireguard-tools gup @@ -35,6 +16,5 @@ in pkgs.mkShell { knot-dns yq nvfetcher.defaultPackage.${system} - ca - ]; + ]); } diff --git a/tools/ca/default.nix b/tools/ca/default.nix new file mode 100644 index 00000000..c5fe0cea --- /dev/null +++ b/tools/ca/default.nix @@ -0,0 +1,25 @@ +{ system, self, mach-nix, leapseconds, ... }: +let + pkgs = self.legacyPackages.${system}; +in mach-nix.lib.${system}.buildPythonPackage { + pname = "ca"; + src = pkgs.lib.sourceByRegex ./. ["^setup\.py$" "^ca(/[^/]+.*)?$"]; + version = "0.0.0"; + ignoreDataOutdated = true; + + requirements = '' + cryptography >=38.0.0 + fqdn + atomicwrites + leapseconddata + xkcdpass + ''; + + _.cryptography.buildInputs = with pkgs; [ openssl ]; + + postInstall = '' + wrapProgram $out/bin/ca \ + --set-default LEAPSECONDS_FILE ${leapseconds} \ + --prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [sops])} + ''; +} -- cgit v1.2.3