From 4f8c86858af9ca4291107ac56d5f9817803f43dd Mon Sep 17 00:00:00 2001 From: Gerg-L Date: Tue, 21 May 2024 17:35:17 -0400 Subject: [PATCH] idk it's funny --- hosts/gerg-desktop/git.nix | 4 +- hosts/gerg-desktop/main.nix | 9 ++++- hosts/gerg-desktop/services/ddns.nix | 3 +- hosts/gerg-desktop/services/gitea.nix | 4 +- hosts/gerg-desktop/services/minecraft.nix | 4 +- hosts/gerg-desktop/services/miniflux.nix | 3 +- hosts/gerg-desktop/services/nextcloud.nix | 4 +- hosts/gerg-desktop/services/nginx.nix | 4 +- hosts/gerg-desktop/services/parrot.nix | 4 +- hosts/gerg-desktop/services/postgresql.nix | 4 +- hosts/gerg-desktop/services/searxng.nix | 4 +- hosts/gerg-desktop/spicetify.nix | 8 ++-- hosts/gerg-desktop/vfio.nix | 10 ++--- hosts/gerg-desktop/zfs.nix | 4 +- hosts/iso/main.nix | 8 +++- hosts/media-laptop/main.nix | 4 +- lib/default.nix | 47 ++++++++++++++++------ modules/DE/dwm.nix | 8 +++- modules/DE/gnome.nix | 4 +- modules/DE/xfce.nix | 4 +- modules/DM/autoLogin.nix | 4 +- modules/DM/lightDM.nix | 4 +- modules/X11.nix | 4 +- modules/boot.nix | 4 +- modules/builders.nix | 4 +- modules/hardware.nix | 4 +- modules/keys.nix | 4 +- modules/misc.nix | 4 +- modules/nix.nix | 14 ++++--- modules/shell.nix | 4 +- modules/sops.nix | 8 +++- modules/theming.nix | 4 +- 32 files changed, 127 insertions(+), 79 deletions(-) diff --git a/hosts/gerg-desktop/git.nix b/hosts/gerg-desktop/git.nix index 2aa1c1b..4a69ad1 100644 --- a/hosts/gerg-desktop/git.nix +++ b/hosts/gerg-desktop/git.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { pkgs, config, ... }: { programs.git = { @@ -30,5 +30,5 @@ _: commit.gpgsign = true; }; }; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/main.nix b/hosts/gerg-desktop/main.nix index b778a50..9a91af3 100644 --- a/hosts/gerg-desktop/main.nix +++ b/hosts/gerg-desktop/main.nix @@ -1,4 +1,8 @@ -{ nvim-flake, self, ... }: +{ + nvim-flake, + self, + _file, +}: { pkgs, config, ... }: { local = { @@ -34,6 +38,7 @@ "amdgpu" ]; }; + services.gnome.gnome-keyring.enable = true; programs.steam.enable = true; @@ -179,5 +184,5 @@ }; system.stateVersion = "23.05"; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/services/ddns.nix b/hosts/gerg-desktop/services/ddns.nix index f58c5e5..faf5143 100644 --- a/hosts/gerg-desktop/services/ddns.nix +++ b/hosts/gerg-desktop/services/ddns.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { config, pkgs, ... }: { sops.secrets.cloudflare = { }; @@ -84,4 +84,5 @@ _: func "nix-fu.com" "cc2df9163c3730f58b866409ac5a108c" ''; }; + inherit _file; } diff --git a/hosts/gerg-desktop/services/gitea.nix b/hosts/gerg-desktop/services/gitea.nix index 9f59f6a..ba4878e 100644 --- a/hosts/gerg-desktop/services/gitea.nix +++ b/hosts/gerg-desktop/services/gitea.nix @@ -1,4 +1,4 @@ -_: +{ _file }: #{ config, ... }: { # users.users = { @@ -30,5 +30,5 @@ _: createDatabase = true; }; }; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/services/minecraft.nix b/hosts/gerg-desktop/services/minecraft.nix index 1e07a10..2940696 100644 --- a/hosts/gerg-desktop/services/minecraft.nix +++ b/hosts/gerg-desktop/services/minecraft.nix @@ -1,4 +1,4 @@ -{ self, ... }: +{ _file, self }: { lib, ... }: { # I manually switch this sometimes @@ -100,5 +100,5 @@ ''; }; }; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/services/miniflux.nix b/hosts/gerg-desktop/services/miniflux.nix index 780f67f..be7d258 100644 --- a/hosts/gerg-desktop/services/miniflux.nix +++ b/hosts/gerg-desktop/services/miniflux.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { config, lib, @@ -97,4 +97,5 @@ _: ${config.services.nginx.user}.extraGroups = [ "miniflux" ]; }; }; + inherit _file; } diff --git a/hosts/gerg-desktop/services/nextcloud.nix b/hosts/gerg-desktop/services/nextcloud.nix index 0090760..80b6ed1 100644 --- a/hosts/gerg-desktop/services/nextcloud.nix +++ b/hosts/gerg-desktop/services/nextcloud.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { pkgs, config, ... }: { #sops.secrets.nextcloud.owner = "nextcloud"; @@ -22,5 +22,5 @@ _: default_phone_region = "US"; }; }; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/services/nginx.nix b/hosts/gerg-desktop/services/nginx.nix index 5d5d1c0..c41ef41 100644 --- a/hosts/gerg-desktop/services/nginx.nix +++ b/hosts/gerg-desktop/services/nginx.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { config, lib, ... }: { sops.secrets = @@ -65,5 +65,5 @@ _: 80 443 ]; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/services/parrot.nix b/hosts/gerg-desktop/services/parrot.nix index 38c4bb7..b1af796 100644 --- a/hosts/gerg-desktop/services/parrot.nix +++ b/hosts/gerg-desktop/services/parrot.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { pkgs, config, @@ -22,5 +22,5 @@ _: RestartSec = "30s"; }; }; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/services/postgresql.nix b/hosts/gerg-desktop/services/postgresql.nix index cddf359..c791bc0 100644 --- a/hosts/gerg-desktop/services/postgresql.nix +++ b/hosts/gerg-desktop/services/postgresql.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { config, pkgs, ... }: { services.postgresql = { @@ -19,5 +19,5 @@ _: settings.unix_socket_permissions = "0770"; }; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/services/searxng.nix b/hosts/gerg-desktop/services/searxng.nix index d753d22..45e7aeb 100644 --- a/hosts/gerg-desktop/services/searxng.nix +++ b/hosts/gerg-desktop/services/searxng.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { config, pkgs, ... }: { sops.secrets.searxngenv = { }; @@ -36,5 +36,5 @@ _: ui.theme_args.simple_style = "dark"; }; }; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/spicetify.nix b/hosts/gerg-desktop/spicetify.nix index 0575af6..edee8ea 100644 --- a/hosts/gerg-desktop/spicetify.nix +++ b/hosts/gerg-desktop/spicetify.nix @@ -1,4 +1,4 @@ -{ spicetify-nix, ... }: +{ spicetify-nix, _file }: let spicePkgs = spicetify-nix.legacyPackages; in @@ -7,7 +7,9 @@ in local.allowedUnfree = [ "spotify" ]; programs.spicetify = { enable = true; - enabledCustomApps = builtins.attrValues { inherit (spicePkgs.apps) lyricsPlus; }; + enabledCustomApps = builtins.attrValues { + inherit (spicePkgs.apps) lyricsPlus ncsVisualizer marketplace; + }; enabledExtensions = builtins.attrValues { inherit (spicePkgs.extensions) adblock @@ -37,5 +39,5 @@ in misc = "282a36"; }; }; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/vfio.nix b/hosts/gerg-desktop/vfio.nix index 466ce18..75d5b56 100644 --- a/hosts/gerg-desktop/vfio.nix +++ b/hosts/gerg-desktop/vfio.nix @@ -1,4 +1,4 @@ -{ self, ... }: +{ _dir, _file }: { pkgs, lib, @@ -27,8 +27,8 @@ let in { environment.etc = { - "Xorg/1_mon.conf".source = "${self}/hosts/gerg-desktop/1_mon.conf"; - "Xorg/2_mon.conf".source = "${self}/hosts/gerg-desktop/2_mon.conf"; + "Xorg/1_mon.conf".source = "${_dir}/1_mon.conf"; + "Xorg/2_mon.conf".source = "${_dir}/2_mon.conf"; }; services.xserver = { @@ -45,7 +45,7 @@ in "L /etc/X11/xorg.conf.d/99-custom.conf - - - - /etc/Xorg/2_mon.conf" # Everything from here down is almost sane - "L+ /var/lib/libvirt/qemu/Windows.xml - - - - ${self}/hosts/gerg-desktop/Windows.xml" + "L+ /var/lib/libvirt/qemu/Windows.xml - - - - ${_dir}/Windows.xml" ]; boot = { @@ -182,5 +182,5 @@ in ); }; - #_file + inherit _file; } diff --git a/hosts/gerg-desktop/zfs.nix b/hosts/gerg-desktop/zfs.nix index 03e309c..d6e573f 100644 --- a/hosts/gerg-desktop/zfs.nix +++ b/hosts/gerg-desktop/zfs.nix @@ -1,4 +1,4 @@ -{ lanzaboote, ... }: +{ lanzaboote, _file }: { config, lib, @@ -91,5 +91,5 @@ efi.efiSysMountPoint = "/efi"; }; }; - #_file + inherit _file; } diff --git a/hosts/iso/main.nix b/hosts/iso/main.nix index d8e9d78..e3db36e 100644 --- a/hosts/iso/main.nix +++ b/hosts/iso/main.nix @@ -1,4 +1,8 @@ -{ disko, nixos-generators, ... }: +{ + disko, + nixos-generators, + _file, +}: { lib, modulesPath, @@ -39,5 +43,5 @@ edition = lib.mkForce "gerg-minimal"; isoName = lib.mkForce "NixOS"; }; - #_file + inherit _file; } diff --git a/hosts/media-laptop/main.nix b/hosts/media-laptop/main.nix index f0f5370..6f8bfa3 100644 --- a/hosts/media-laptop/main.nix +++ b/hosts/media-laptop/main.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { lib, pkgs, @@ -84,5 +84,5 @@ _: size = 8 * 1024; } ]; - #_file + inherit _file; } diff --git a/lib/default.nix b/lib/default.nix index 0b3ded0..cc72b17 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -34,14 +34,6 @@ rec { (builtins.filter (lib.hasSuffix ".nix")) ]; - fixModuleSystem = - file: - lib.pipe file [ - builtins.readFile - (builtins.replaceStrings [ "#_file" ] [ "_file = \"${file}\";" ]) - (builtins.toFile (builtins.baseNameOf file)) - ]; - mkModules = path: lib.pipe path [ @@ -51,7 +43,7 @@ rec { (lib.removeSuffix ".nix") (lib.removePrefix "${path}/") ]; - value = fixModuleSystem name; + value = name; })) builtins.listToAttrs ]; @@ -83,11 +75,42 @@ rec { modules = let - importWithInputs' = map (x: import x (constructInputs' system inputs)); + importWithArgs = map ( + x: + let + allArgs = (constructInputs' system inputs) // { + inherit inputs; + _dir = + let + dir = builtins.dirOf x; + in + if (dir != builtins.storeDir) then dir else null; + _file = x; + }; + imported = import x; + in + lib.pipe imported [ + lib.functionArgs + builtins.attrNames + (map ( + x: + if allArgs ? ${x} then + { + name = x; + value = allArgs.${x}; + } + else + null + )) + (builtins.filter builtins.isAttrs) + builtins.listToAttrs + imported + ] + ); in builtins.concatLists [ - (importWithInputs' (builtins.attrValues self.nixosModules)) - (importWithInputs' (map fixModuleSystem (listNixFilesRecursive "${self}/hosts/${hostName}"))) + (importWithArgs (builtins.attrValues self.nixosModules)) + (importWithArgs (listNixFilesRecursive "${self}/hosts/${hostName}")) (import "${unstable}/nixos/modules/module-list.nix") (lib.singleton { networking = { diff --git a/modules/DE/dwm.nix b/modules/DE/dwm.nix index 9ba06f0..ce68d04 100644 --- a/modules/DE/dwm.nix +++ b/modules/DE/dwm.nix @@ -1,4 +1,8 @@ -{ suckless, self, ... }: +{ + suckless, + self, + _file, +}: { pkgs, config, @@ -121,5 +125,5 @@ }; }; }; - #_file + inherit _file; } diff --git a/modules/DE/gnome.nix b/modules/DE/gnome.nix index 16f756e..83f6c3d 100644 --- a/modules/DE/gnome.nix +++ b/modules/DE/gnome.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { config, lib, @@ -50,5 +50,5 @@ _: }; }; }; - #_file + inherit _file; } diff --git a/modules/DE/xfce.nix b/modules/DE/xfce.nix index 26d5d14..a5872e9 100644 --- a/modules/DE/xfce.nix +++ b/modules/DE/xfce.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { config, lib, @@ -21,5 +21,5 @@ _: displayManager.defaultSession = "xfce"; }; }; - #_file + inherit _file; } diff --git a/modules/DM/autoLogin.nix b/modules/DM/autoLogin.nix index c17f8d0..230b6a0 100644 --- a/modules/DM/autoLogin.nix +++ b/modules/DM/autoLogin.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { config, lib, ... }: { options.local.DM = { @@ -17,5 +17,5 @@ _: }; }; }; - #_file + inherit _file; } diff --git a/modules/DM/lightDM.nix b/modules/DM/lightDM.nix index 053a8a6..584aad6 100644 --- a/modules/DM/lightDM.nix +++ b/modules/DM/lightDM.nix @@ -1,4 +1,4 @@ -{ self, ... }: +{ self, _file }: { config, lib, ... }: { options.local.DM.lightdm.enable = lib.mkEnableOption ""; @@ -41,5 +41,5 @@ }; }; }; - #_file + inherit _file; } diff --git a/modules/X11.nix b/modules/X11.nix index 17d96af..aef7533 100644 --- a/modules/X11.nix +++ b/modules/X11.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { pkgs, lib, ... }: { services.xserver = { @@ -9,5 +9,5 @@ _: excludePackages = [ pkgs.xterm ]; desktopManager.xterm.enable = false; }; - #_file + inherit _file; } diff --git a/modules/boot.nix b/modules/boot.nix index 33eb650..8a254c4 100644 --- a/modules/boot.nix +++ b/modules/boot.nix @@ -1,4 +1,4 @@ -{ self, ... }: +{ self, _file }: { lib, pkgs, @@ -68,5 +68,5 @@ ''; }; }; - #_file + inherit _file; } diff --git a/modules/builders.nix b/modules/builders.nix index 145048d..9bdabc7 100644 --- a/modules/builders.nix +++ b/modules/builders.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { config, lib, ... }: { options.local.remoteBuild = { @@ -97,5 +97,5 @@ _: } ) ]; - #_file + inherit _file; } diff --git a/modules/hardware.nix b/modules/hardware.nix index aaf8bbe..37e8d0a 100644 --- a/modules/hardware.nix +++ b/modules/hardware.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { config, lib, ... }: let cfg = config.local.hardware; @@ -41,5 +41,5 @@ in }; } ]; - #_file + inherit _file; } diff --git a/modules/keys.nix b/modules/keys.nix index 1e34223..287d7c7 100644 --- a/modules/keys.nix +++ b/modules/keys.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { lib, ... }: { options.local.keys = lib.mkOption { }; @@ -12,5 +12,5 @@ _: gerg-desktop_fingerprint = "BQxvBOWsTw1gdNDR0KzrSRmbVhDrJdG05vYXkVmw8yA"; gerg_gerg-desktop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJWbwkFJmRBgyWyWU+w3ksZ+KuFw9uXJN3PwqqE7Z/i8"; }; - #_file + inherit _file; } diff --git a/modules/misc.nix b/modules/misc.nix index 7ca60e8..f97a869 100644 --- a/modules/misc.nix +++ b/modules/misc.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { lib, config, @@ -68,5 +68,5 @@ _: # Useless with flakes (without configuring) programs.command-not-found.enable = false; }; - #_file + inherit _file; } diff --git a/modules/nix.nix b/modules/nix.nix index 4a989f4..82745e7 100644 --- a/modules/nix.nix +++ b/modules/nix.nix @@ -1,4 +1,8 @@ -inputs': +{ + nix, + inputs, + _file, +}: { lib, config, @@ -9,10 +13,10 @@ inputs': # # Flake registry and $NIX_PATH pinning # - nix.registry = lib.pipe inputs' [ + nix.registry = lib.pipe inputs [ (lib.filterAttrs (_: lib.isType "flake")) (lib.mapAttrs (_: flake: { inherit flake; })) - (x: x // { nixpkgs.flake = inputs'.unstable; }) + (x: x // { nixpkgs.flake = inputs.unstable; }) ]; environment.etc = lib.mapAttrs' (name: value: { @@ -27,7 +31,7 @@ inputs': # # Use nix directly from master # - nix.package = inputs'.nix.packages.default.overrideAttrs (old: { + nix.package = nix.packages.default.overrideAttrs (old: { patches = old.patches or [ ] ++ [ (pkgs.fetchpatch { url = "https://github.com/NixOS/nix/commit/b6ae3be9c6ec4e9de55479188e76fc330b2304dd.patch"; @@ -69,5 +73,5 @@ inputs': # reject-flake-config = true; }; - #_file + inherit _file; } diff --git a/modules/shell.nix b/modules/shell.nix index a0a79b3..68ad0bd 100644 --- a/modules/shell.nix +++ b/modules/shell.nix @@ -1,4 +1,4 @@ -{ fetch-rs, ... }: +{ fetch-rs, _file }: { pkgs, config, @@ -160,5 +160,5 @@ }; }; }; - #_file + inherit _file; } diff --git a/modules/sops.nix b/modules/sops.nix index 131e840..359d63c 100644 --- a/modules/sops.nix +++ b/modules/sops.nix @@ -1,4 +1,8 @@ -{ sops-nix, self, ... }: +{ + sops-nix, + self, + _file, +}: { pkgs, config, @@ -15,5 +19,5 @@ age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; }; }; - #_file + inherit _file; } diff --git a/modules/theming.nix b/modules/theming.nix index 60ad3b4..cf23a51 100644 --- a/modules/theming.nix +++ b/modules/theming.nix @@ -1,4 +1,4 @@ -_: +{ _file }: { pkgs, config, @@ -98,5 +98,5 @@ in }; }) ]; - #_file + inherit _file; }