move function to lib/extended

This commit is contained in:
Daylin Morgan 2024-06-18 10:13:24 -05:00
parent 0e132b9372
commit 77045fc4d2
Signed by: daylin
GPG Key ID: 950D13E9719334AD
4 changed files with 24 additions and 15 deletions

View File

@ -56,7 +56,7 @@ in
oizys-zig = pkgs.callPackage ../pkgs/oizys/oizys-zig { inherit zig2nix; };
oizys-nim = pkgs.callPackage ../pkgs/oizys/oizys-nim { };
oizys-rs = pkgs.callPackage ../pkgs/oizys/oizys-rs { };
oizys-go = pkgs.callPackage ../pkgs/oizys/oizys-go { inherit self;};
oizys-go = pkgs.callPackage ../pkgs/oizys/oizys-go { inherit self lib; };
default = oizys-go;
});
devShells = forAllSystems (pkgs: {

View File

@ -1,12 +1,14 @@
final: prev:
let
inherit (final)
concatStringsSep
hasSuffix
mkEnableOption
mkIf
mkOption
types
;
inherit (builtins) listToAttrs substring;
in
rec {
enabled = {
@ -19,7 +21,7 @@ rec {
# ["a" "b"] -> {a.enable = true; b.enable = true;}
enableAttrs =
attrs:
builtins.listToAttrs (
listToAttrs (
map (attr: {
name = attr;
value = enabled;
@ -28,7 +30,7 @@ rec {
# ["a" "b"] -> {a.enable = false; b.enable = false;}
disableAttrs =
attrs:
builtins.listToAttrs (
listToAttrs (
map (attr: {
name = attr;
value = disabled;
@ -50,4 +52,13 @@ rec {
};
config = mkIf config.oizys.${attr}.enable content;
};
# generate date string with '-' from long date
mkDate =
longDate:
(concatStringsSep "-" [
(substring 0 4 longDate)
(substring 4 2 longDate)
(substring 6 2 longDate)
]);
}

View File

@ -26,7 +26,6 @@
pkgs.nixfmt-rfc-style
pkgs.nix-output-monitor
self.packages.${pkgs.system}.default
];

View File

@ -8,20 +8,14 @@
nix-output-monitor,
...
}:
let
mkDate =
longDate:
(lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
let
inherit (lib) mkDate cleanSource makeBinPath;
in
buildGoModule {
pname = "oizys";
version = "date=${mkDate self.lastModifiedDate}";
version = "d${mkDate self.lastModifiedDate}";
src = lib.cleanSource ./.;
src = cleanSource ./.;
vendorHash = "sha256-Geqcp0/7I1IF2IfaYyIChz7SOCF+elIEdcz2VsAU0hQ=";
nativeBuildInputs = [
@ -36,6 +30,11 @@ buildGoModule {
postFixup = ''
wrapProgram $out/bin/oizys \
--prefix PATH ':' ${lib.makeBinPath [ gh nix-output-monitor ]}
--prefix PATH ':' ${
makeBinPath [
gh
nix-output-monitor
]
}
'';
}