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-zig = pkgs.callPackage ../pkgs/oizys/oizys-zig { inherit zig2nix; };
oizys-nim = pkgs.callPackage ../pkgs/oizys/oizys-nim { }; oizys-nim = pkgs.callPackage ../pkgs/oizys/oizys-nim { };
oizys-rs = pkgs.callPackage ../pkgs/oizys/oizys-rs { }; 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; default = oizys-go;
}); });
devShells = forAllSystems (pkgs: { devShells = forAllSystems (pkgs: {

View File

@ -1,12 +1,14 @@
final: prev: final: prev:
let let
inherit (final) inherit (final)
concatStringsSep
hasSuffix hasSuffix
mkEnableOption mkEnableOption
mkIf mkIf
mkOption mkOption
types types
; ;
inherit (builtins) listToAttrs substring;
in in
rec { rec {
enabled = { enabled = {
@ -19,7 +21,7 @@ rec {
# ["a" "b"] -> {a.enable = true; b.enable = true;} # ["a" "b"] -> {a.enable = true; b.enable = true;}
enableAttrs = enableAttrs =
attrs: attrs:
builtins.listToAttrs ( listToAttrs (
map (attr: { map (attr: {
name = attr; name = attr;
value = enabled; value = enabled;
@ -28,7 +30,7 @@ rec {
# ["a" "b"] -> {a.enable = false; b.enable = false;} # ["a" "b"] -> {a.enable = false; b.enable = false;}
disableAttrs = disableAttrs =
attrs: attrs:
builtins.listToAttrs ( listToAttrs (
map (attr: { map (attr: {
name = attr; name = attr;
value = disabled; value = disabled;
@ -50,4 +52,13 @@ rec {
}; };
config = mkIf config.oizys.${attr}.enable content; 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.nixfmt-rfc-style
pkgs.nix-output-monitor pkgs.nix-output-monitor
self.packages.${pkgs.system}.default self.packages.${pkgs.system}.default
]; ];

View File

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