From 0b3f9cb9fde5929f361e91f6ed5b43958665f3d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Sat, 11 Apr 2020 20:53:31 +0200 Subject: [PATCH] Adjust some library functions --- lib/default.nix | 28 ++++++---------------------- modules/private/gitolite/default.nix | 16 ++++++++-------- modules/private/ssh/default.nix | 11 +++++------ 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 6b3dfdf..86832d4 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -17,7 +17,8 @@ rec { json = lib.importJSON path; in rec { version = json.tag; - name = "${json.meta.name}-${version}"; + pname = json.meta.name; + name = "${pname}-${version}"; src = fetchFromGitHub json.github; }; @@ -26,7 +27,8 @@ rec { json = lib.importJSON path; in rec { version = json.tag; - name = "${json.meta.name}-${version}"; + pname = json.meta.name; + name = "${pname}-${version}"; src = fetchgit json.git; }; @@ -35,30 +37,12 @@ rec { json = lib.importJSON path; in rec { version = json.tag; - name = "${json.meta.name}-${version}"; + pname = json.meta.name; + name = "${pname}-${version}"; src = builtins.fetchGit { url = json.git.url; ref = "master"; rev = json.git.rev; }; }; - - wrap = { paths ? [], vars ? {}, file ? null, script ? null, name ? "wrap" }: - assert file != null || script != null || - abort "wrap needs 'file' or 'script' argument"; - with rec { - set = n: v: "--set ${pkgs.lib.escapeShellArg n} " + - "${pkgs.lib.escapeShellArg v}"; - args = (map (p: "--prefix PATH : ${p}/bin") paths) ++ - (builtins.attrValues (pkgs.lib.mapAttrs set vars)); - }; - runCommand name - { - f = if file == null then writeScript name script else file; - buildInputs = [ makeWrapper ]; - } - '' - makeWrapper "$f" "$out" ${toString args} - ''; - } // (if builtins.pathExists ./private then callPackage ./private {} else {}) diff --git a/modules/private/gitolite/default.nix b/modules/private/gitolite/default.nix index 9f5c179..1549c94 100644 --- a/modules/private/gitolite/default.nix +++ b/modules/private/gitolite/default.nix @@ -28,14 +28,14 @@ in { }; system.activationScripts.gitolite = let - gitolite_ldap_groups = pkgs.mylibs.wrap { - name = "gitolite_ldap_groups.sh"; - file = ./gitolite_ldap_groups.sh; - vars = { - LDAP_PASS = config.myEnv.tools.gitolite.ldap.password; - }; - paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.coreutils ]; - }; + deps = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.coreutils ]; + gitolite_ldap_groups = pkgs.runCommand "gitolite_ldap_groups.sh" { + buildInputs = [ pkgs.makeWrapper ]; + } '' + makeWrapper "${./gitolite_ldap_groups.sh}" "$out" \ + --prefix PATH : ${lib.makeBinPath deps} \ + --set LDAP_PASS ${pkgs.lib.escapeShellArg config.myEnv.tools.gitolite.ldap.password} + ''; in { deps = [ "users" ]; text = '' diff --git a/modules/private/ssh/default.nix b/modules/private/ssh/default.nix index 1699104..aea3ac0 100644 --- a/modules/private/ssh/default.nix +++ b/modules/private/ssh/default.nix @@ -77,12 +77,11 @@ in substituteAll ${./ldap_authorized_keys.sh} $out chmod a+x $out ''; - ldap_authorized_keys = - pkgs.mylibs.wrap { - name = "ldap_authorized_keys"; - file = fullScript; - paths = deps; - }; + ldap_authorized_keys = pkgs.runCommand "ldap_authorized_keys" { + buildInputs = [ pkgs.makeWrapper ]; + } '' + makeWrapper "${fullScript}" "$out" --prefix PATH : ${lib.makeBinPath deps} + ''; in { enable = true; mode = "0755"; -- 2.41.0