aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cfgWrapper.nix63
-rw-r--r--lib/lib.nix52
-rw-r--r--lib/nix-furnace/default.nix31
3 files changed, 58 insertions, 88 deletions
diff --git a/lib/cfgWrapper.nix b/lib/cfgWrapper.nix
deleted file mode 100644
index 2e57656..0000000
--- a/lib/cfgWrapper.nix
+++ /dev/null
@@ -1,63 +0,0 @@
-{pkgs}: {
- pkg,
- binName ? pkg.meta.mainProgram,
- extraFlags ? [],
- extraWrapperFlags ? [],
- extraPkgs ? [],
- extraEnv ? {},
- postBuild ? "",
- hidePkgs ? false,
- reducePath ? false,
-}: let
- extraFlagsArgs = pkgs.lib.pipe extraFlags [
- (builtins.map (x: ''--add-flags "${x}" ''))
- (builtins.concatStringsSep " ")
- ];
-
- extraWrapperFlagsArgs = builtins.concatStringsSep " " extraWrapperFlags;
-
- pathArg =
- if (extraPkgs != [])
- then ''--prefix PATH : "${pkgs.lib.makeBinPath extraPkgs}"''
- else "";
-
- # Looks like {
- # VAR = "value";
- # VAR2 = "value_again";
- # }
- envArgs = pkgs.lib.pipe extraEnv [
- (builtins.mapAttrs (k: v: ''--set ${k} "${v}"''))
- builtins.attrValues
- (builtins.concatStringsSep " ")
- ];
-
- extraPkgs2 =
- if reducePath
- then
- (pkgs.symlinkJoin {
- name = "${binName}-extra-pkgs";
- paths = extraPkgs;
- })
- else extraPkgs;
-
- wrapped-program = pkgs.symlinkJoin {
- name = "${binName}-wrapped-program";
- paths = [pkg] ++ extraPkgs2;
-
- buildInputs = [pkgs.makeWrapper];
- postBuild = ''
- ${postBuild}
-
- wrapProgram $out/bin/${binName} ${extraFlagsArgs} ${pathArg} ${envArgs} ${extraWrapperFlagsArgs}
- '';
- };
-in
- if hidePkgs
- then
- (pkgs.linkFarm "${binName}-only-bin" [
- {
- name = "bin/${binName}";
- path = "${wrapped-program}/bin/${binName}";
- }
- ])
- else wrapped-program
diff --git a/lib/lib.nix b/lib/lib.nix
new file mode 100644
index 0000000..5310a6d
--- /dev/null
+++ b/lib/lib.nix
@@ -0,0 +1,52 @@
+let
+ optionalAttrs = cond: as:
+ if cond
+ then as
+ else {};
+
+ mkIfNull = cond: as:
+ if cond
+ then as
+ else null;
+
+ globimport = {
+ lazyImport = path: optionalAttrs (builtins.pathExists path) (import path);
+
+ getSubdirs = dir:
+ builtins.filter (x: x != null)
+ (builtins.attrValues
+ (builtins.mapAttrs
+ (name: value: mkIfNull (value == "directory") name)
+ (builtins.readDir dir)));
+
+ getSubfiles = dir:
+ builtins.filter (x: x != null)
+ (builtins.attrValues
+ (builtins.mapAttrs
+ (name: value: mkIfNull (value == "file") name)
+ (builtins.readDir dir)));
+ };
+
+ options = {
+ lib,
+ config,
+ }: let
+ inherit (lib) mkOption mkEnableOption;
+ mkProgramOption' = name: extraOpts:
+ {
+ enable = mkEnableOption "whether to enable ${name}";
+ theme = mkOption {
+ type = lib.types.enum ["catppuccin" "adwaita"];
+ default = config.collinux.terminal.theme;
+ };
+ }
+ // extraOpts;
+
+ mkProgramOption = name: mkProgramOption' name {};
+ in {
+ inherit mkProgramOption' mkProgramOption;
+ };
+in {
+ inherit globimport;
+ inherit options;
+}
diff --git a/lib/nix-furnace/default.nix b/lib/nix-furnace/default.nix
index 7c18ae9..303730e 100644
--- a/lib/nix-furnace/default.nix
+++ b/lib/nix-furnace/default.nix
@@ -1,27 +1,6 @@
let
- lazyImport = path:
- if (builtins.pathExists path)
- then import path
- else {};
-
- mkIfNull = cond: onTrue:
- if cond
- then onTrue
- else null;
-
- getSubdirs = dir:
- builtins.filter (x: x != null)
- (builtins.attrValues
- (builtins.mapAttrs
- (name: value: mkIfNull (value == "directory") name)
- (builtins.readDir dir)));
-
- getSubfiles = dir:
- builtins.filter (x: x != null)
- (builtins.attrValues
- (builtins.mapAttrs
- (name: value: mkIfNull (value == "file") name)
- (builtins.readDir dir)));
+ my-lib = import ../lib.nix;
+ inherit (my-lib.globimport) lazyImport getSubdirs getSubfiles;
mkHomeImports = modName: [
(lazyImport ../../modules/${modName}/options.nix)
@@ -65,9 +44,11 @@ let
};
};
};
+
+ specialArgs = {inherit inputs my-lib;};
in
inputs.nixpkgs.lib.nixosSystem {
- specialArgs = {inherit inputs;};
+ inherit specialArgs;
modules =
[
{networking.hostName = hostname;}
@@ -85,7 +66,7 @@ let
backupFileExtension = "bak";
useGlobalPkgs = true;
useUserPackages = true;
- extraSpecialArgs = {inherit inputs;};
+ extraSpecialArgs = specialArgs;
users."${username}" = {
imports =
[