diff --git a/apps/run-workflow-with-vm/configuration.nix b/apps/run-workflow-with-vm/configuration.nix index 6d0ea257..e78dd456 100644 --- a/apps/run-workflow-with-vm/configuration.nix +++ b/apps/run-workflow-with-vm/configuration.nix @@ -7,8 +7,7 @@ let pkgs = import { }; lib = pkgs.lib; -in -import { +in import { inherit lib; specialArgs = { foodogsquaredUtils = import { inherit lib; }; diff --git a/apps/run-workflow-with-vm/default.nix b/apps/run-workflow-with-vm/default.nix index b705155a..0ee900ee 100644 --- a/apps/run-workflow-with-vm/default.nix +++ b/apps/run-workflow-with-vm/default.nix @@ -1,9 +1,4 @@ -{ stdenv -, lib -, meson -, ninja -, inputs ? [ ] -}: +{ stdenv, lib, meson, ninja, inputs ? [ ] }: stdenv.mkDerivation (finalAttrs: { pname = "run-workflow-with-vm"; @@ -11,10 +6,7 @@ stdenv.mkDerivation (finalAttrs: { src = ./.; - nativeBuildInputs = [ - meson - ninja - ]; + nativeBuildInputs = [ meson ninja ]; preConfigure = '' mesonFlagsArray+=("-Dinputs=[${lib.concatStringsSep "," inputs}]") diff --git a/apps/run-workflow-with-vm/modules/home-manager/default.nix b/apps/run-workflow-with-vm/modules/home-manager/default.nix index cf25d998..cd01f253 100644 --- a/apps/run-workflow-with-vm/modules/home-manager/default.nix +++ b/apps/run-workflow-with-vm/modules/home-manager/default.nix @@ -1,2 +1,4 @@ # It's just be empty like your soul, probably. -{ imports = [ ]; } +{ + imports = [ ]; +} diff --git a/apps/run-workflow-with-vm/modules/nixos/default.nix b/apps/run-workflow-with-vm/modules/nixos/default.nix index 9d0801c6..c5ea65a5 100644 --- a/apps/run-workflow-with-vm/modules/nixos/default.nix +++ b/apps/run-workflow-with-vm/modules/nixos/default.nix @@ -1,3 +1,5 @@ # Just an extra set of modules, if you count zero modules as one. Or I guess # technically this is one module, just an empty one. -{ imports = [ ]; } +{ + imports = [ ]; +} diff --git a/configs/disko/laptop-ssd/default.nix b/configs/disko/laptop-ssd/default.nix index 1f8b708a..0e8d80c5 100644 --- a/configs/disko/laptop-ssd/default.nix +++ b/configs/disko/laptop-ssd/default.nix @@ -17,13 +17,8 @@ subvolumes = { "/root" = { - mountOptions = [ - "rw" - "user" - "noauto" - "nofail" - "compress=zstd:10" - ]; + mountOptions = + [ "rw" "user" "noauto" "nofail" "compress=zstd:10" ]; mountpoint = "/media/laptop-ssd"; }; }; diff --git a/configs/flake-parts/default.nix b/configs/flake-parts/default.nix index 9af49986..bf692cbc 100644 --- a/configs/flake-parts/default.nix +++ b/configs/flake-parts/default.nix @@ -28,9 +28,7 @@ defaultSystems = [ "x86_64-linux" ]; }; - setups.sharedNixpkgsConfig = { - allowUnfree = true; - }; + setups.sharedNixpkgsConfig = { allowUnfree = true; }; perSystem = { lib, system, ... }: { _module.args = { @@ -39,9 +37,8 @@ pkgs = import inputs.nixpkgs { inherit system; config = config.setups.sharedNixpkgsConfig; - overlays = lib.attrValues inputs.self.overlays ++ [ - inputs.nur.overlays.default - ]; + overlays = lib.attrValues inputs.self.overlays + ++ [ inputs.nur.overlays.default ]; }; }; }; diff --git a/configs/flake-parts/home-manager.nix b/configs/flake-parts/home-manager.nix index 6a5bd0e9..10ce29ce 100644 --- a/configs/flake-parts/home-manager.nix +++ b/configs/flake-parts/home-manager.nix @@ -1,11 +1,8 @@ -{ inputs -, lib -, config +{ inputs, lib, config , defaultNixConf -, ... -}: +, ... }: { setups.home-manager = { @@ -42,8 +39,7 @@ { _module.args = { firstSetupArgs = { - baseNixvimModules = - config.setups.nixvim.configs.fiesta.modules + baseNixvimModules = config.setups.nixvim.configs.fiesta.modules ++ config.setups.nixvim.sharedModules; }; }; diff --git a/configs/flake-parts/nixos.nix b/configs/flake-parts/nixos.nix index 6aaaf11d..486065bf 100644 --- a/configs/flake-parts/nixos.nix +++ b/configs/flake-parts/nixos.nix @@ -2,14 +2,12 @@ , defaultNixConf -, ... -}: +, ... }: let domain = "foodogsquared.one"; subdomain = name: "${name}.${domain}"; -in -{ +in { setups.nixos = { configs = { # The main desktop. @@ -17,10 +15,8 @@ in nixpkgs.branch = "nixos-unstable"; # This is to make an exception for Archivebox. - nixpkgs.config.permittedInsecurePackages = [ - "archiver-3.5.1" - "python3.12-django-3.1.14" - ]; + nixpkgs.config.permittedInsecurePackages = + [ "archiver-3.5.1" "python3.12-django-3.1.14" ]; systems = [ "x86_64-linux" ]; formats = null; @@ -30,10 +26,8 @@ in inputs.wrapper-manager-fds.nixosModules.wrapper-manager { - documentation.nixos.extraModules = [ - ../../modules/nixos - ../../modules/nixos/_private - ]; + documentation.nixos.extraModules = + [ ../../modules/nixos ../../modules/nixos/_private ]; wrapper-manager.documentation.manpage.enable = true; wrapper-manager.documentation.extraModules = [ ../../modules/wrapper-manager @@ -44,9 +38,8 @@ in inputs.nixos-hardware.nixosModules.common-cpu-amd-pstate inputs.nixos-hardware.nixosModules.common-cpu-amd-raphael-igpu - ( - { config, ... }: let - hmCfg = config.home-manager.users; + ({ config, ... }: + let hmCfg = config.home-manager.users; in { # Testing out Nushell for a spinerooski. users.users.foo-dogsquared.shell = @@ -54,8 +47,7 @@ in hmCfg.foo-dogsquared.programs.nushell.package else "/run/current-system/sw/bin/bash"; - } - ) + }) ]; home-manager = { branch = "home-manager-unstable"; @@ -99,10 +91,8 @@ in activationTimeout = 1200; }; - modules = [ - inputs.disko.nixosModules.disko - inputs.sops-nix.nixosModules.sops - ]; + modules = + [ inputs.disko.nixosModules.disko inputs.sops-nix.nixosModules.sops ]; }; # The barely customized non-graphical installer. @@ -126,9 +116,7 @@ in winnowing = { nixpkgs = { branch = "nixos-unstable"; - overlays = [ - inputs.neovim-nightly-overlay.overlays.default - ]; + overlays = [ inputs.neovim-nightly-overlay.overlays.default ]; }; home-manager.branch = "home-manager-unstable"; systems = [ "x86_64-linux" ]; diff --git a/configs/flake-parts/nixvim.nix b/configs/flake-parts/nixvim.nix index b2518fcb..6d7320f5 100644 --- a/configs/flake-parts/nixvim.nix +++ b/configs/flake-parts/nixvim.nix @@ -3,16 +3,12 @@ { setups.nixvim.configs = { fiesta = { - components = [ - { - nixpkgsBranch = "nixos-unstable"; - nixvimBranch = "nixvim-unstable"; - neovimPackage = pkgs: pkgs.neovim; - overlays = [ - inputs.neovim-nightly-overlay.overlays.default - ]; - } - ]; + components = [{ + nixpkgsBranch = "nixos-unstable"; + nixvimBranch = "nixvim-unstable"; + neovimPackage = pkgs: pkgs.neovim; + overlays = [ inputs.neovim-nightly-overlay.overlays.default ]; + }]; }; trovebelt = { @@ -20,10 +16,7 @@ nixpkgsBranch = [ "nixos-unstable" ]; nixvimBranch = [ "nixvim-unstable" ]; neovimPackage = [ (pkgs: pkgs.neovim) ]; - overlays = [ - [ inputs.neovim-nightly-overlay.overlays.default ] - [ ] - ]; + overlays = [ [ inputs.neovim-nightly-overlay.overlays.default ] [ ] ]; }; }; }; @@ -33,7 +26,5 @@ inputs.self.nixvimModules.bahaghari ]; - flake = { - nixvimModules.default = ../../modules/nixvim; - }; + flake = { nixvimModules.default = ../../modules/nixvim; }; } diff --git a/configs/home-manager/alice/default.nix b/configs/home-manager/alice/default.nix index f740dc2a..62a8ec16 100644 --- a/configs/home-manager/alice/default.nix +++ b/configs/home-manager/alice/default.nix @@ -18,13 +18,7 @@ programs.bash = { enable = true; historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; - historyIgnore = [ - "cd" - "exit" - "lf" - "ls" - "nvim" - ]; + historyIgnore = [ "cd" "exit" "lf" "ls" "nvim" ]; }; home.stateVersion = "23.11"; diff --git a/configs/home-manager/foo-dogsquared/default.nix b/configs/home-manager/foo-dogsquared/default.nix index 325344ce..d2f94315 100644 --- a/configs/home-manager/foo-dogsquared/default.nix +++ b/configs/home-manager/foo-dogsquared/default.nix @@ -3,8 +3,7 @@ let inherit (bahaghariLib.tinted-theming) importScheme; userCfg = config.users.foo-dogsquared; -in -{ +in { imports = [ ./modules ]; # All of the home-manager-user-specific setup are here. @@ -30,7 +29,8 @@ in # Merge the upstream since any new files will be overridden. It also # allows us to attach data to it such as new links to the hardcoded # sections. - (lib.importTOML "${config.users.foo-dogsquared.programs.custom-homepage.package.src}/data/foodogsquared-homepage/links.toml") + (lib.importTOML + "${config.users.foo-dogsquared.programs.custom-homepage.package.src}/data/foodogsquared-homepage/links.toml") { services = { @@ -48,26 +48,35 @@ in (lib.mkIf config.services.archivebox.webserver.enable { services.links = lib.singleton { - url = "http://localhost:${builtins.toString config.state.ports.archivebox-webserver.value}"; + url = "http://localhost:${ + builtins.toString + config.state.ports.archivebox-webserver.value + }"; text = "Archive webserver"; }; YOHOOHOOHOOHOO.links = lib.mkBefore (lib.singleton { - url = "http://localhost:${builtins.toString config.state.ports.archivebox-webserver.value}"; + url = "http://localhost:${ + builtins.toString + config.state.ports.archivebox-webserver.value + }"; text = "ArchiveBox webserver"; }); }) - (lib.mkIf (attrs.nixosConfig.suites.filesystem.setups.archive.enable or false) { - YOHOOHOOHOOHOO.links = lib.mkBefore (lib.singleton { - url = "file://${attrs.nixosConfig.state.paths.archive}"; - text = "Personal archive"; - }); - }) + (lib.mkIf + (attrs.nixosConfig.suites.filesystem.setups.archive.enable or false) { + YOHOOHOOHOOHOO.links = lib.mkBefore (lib.singleton { + url = "file://${attrs.nixosConfig.state.paths.archive}"; + text = "Personal archive"; + }); + }) (lib.mkIf (attrs.nixosConfig.services.miniflux.enable or false) { services.links = lib.singleton { - url = "http://localhost:${builtins.toString attrs.nixosConfig.state.ports.miniflux.value}"; + url = "http://localhost:${ + builtins.toString attrs.nixosConfig.state.ports.miniflux.value + }"; text = "RSS reader"; }; }) @@ -101,15 +110,17 @@ in # Add our own projects directory since most programs can't decide where it is # properly. - xdg.userDirs.extraConfig.XDG_PROJECTS_DIR = "${config.home.homeDirectory}/Projects"; + xdg.userDirs.extraConfig.XDG_PROJECTS_DIR = + "${config.home.homeDirectory}/Projects"; # Set nixpkgs config both outside and inside of home-manager. nixpkgs.config = import ./config/nixpkgs/config.nix; xdg.configFile."nixpkgs/config.nix".source = ./config/nixpkgs/config.nix; - home.packages = with pkgs; [ - gopass # An improved version of the password manager for hipsters. - ]; + home.packages = with pkgs; + [ + gopass # An improved version of the password manager for hipsters. + ]; home.stateVersion = "23.11"; @@ -122,24 +133,25 @@ in state.packages = { diff = pkgs.diffoscope; pager = config.programs.bat.package; - editor = - if config.programs.nixvim.enable then - config.programs.nixvim.finalPackage - else - config.programs.neovim.package; + editor = if config.programs.nixvim.enable then + config.programs.nixvim.finalPackage + else + config.programs.neovim.package; }; # Automating some files to be fetched on activation. home.mutableFile = { # ...my gopass secrets,... ".local/share/gopass/stores/personal" = { - url = "gitea@code.foodogsquared.one:foodogsquared/gopass-secrets-personal.git"; + url = + "gitea@code.foodogsquared.one:foodogsquared/gopass-secrets-personal.git"; type = "gopass"; }; # ...and my custom theme to be a showoff. "${config.xdg.dataHome}/base16/bark-on-a-tree" = { - url = "https://github.com/foo-dogsquared/base16-bark-on-a-tree-scheme.git"; + url = + "https://github.com/foo-dogsquared/base16-bark-on-a-tree-scheme.git"; type = "git"; }; }; diff --git a/configs/home-manager/foo-dogsquared/files/homepage/default.nix b/configs/home-manager/foo-dogsquared/files/homepage/default.nix index dd2fae86..a837a4b1 100644 --- a/configs/home-manager/foo-dogsquared/files/homepage/default.nix +++ b/configs/home-manager/foo-dogsquared/files/homepage/default.nix @@ -1,5 +1,5 @@ -{ pkgs ? import { - overlays = [ (import ../../../../../overlays).default ]; -} }: +{ pkgs ? + import { overlays = [ (import ../../../../../overlays).default ]; } +}: pkgs.callPackage ./package.nix { } diff --git a/configs/home-manager/foo-dogsquared/files/homepage/package.nix b/configs/home-manager/foo-dogsquared/files/homepage/package.nix index ae2edc3d..3854a7e4 100644 --- a/configs/home-manager/foo-dogsquared/files/homepage/package.nix +++ b/configs/home-manager/foo-dogsquared/files/homepage/package.nix @@ -1,7 +1,4 @@ -{ - buildHugoSite, - lib, -}: +{ buildHugoSite, lib, }: buildHugoSite { pname = "foodogsquared-hm-startpage"; @@ -11,8 +8,12 @@ buildHugoSite { vendorHash = "sha256-Mi61QK1yKWIneZ+i79fpJqP9ew5r5vnv7ptr9YGq0Uk="; preBuild = '' - install -Dm0644 ${../tinted-theming/base16/bark-on-a-tree.yaml} ./data/foodogsquared-homepage/themes/_dark.yaml - install -Dm0644 ${../tinted-theming/base16/albino-bark-on-a-tree.yaml} ./data/foodogsquared-homepage/themes/_light.yaml + install -Dm0644 ${ + ../tinted-theming/base16/bark-on-a-tree.yaml + } ./data/foodogsquared-homepage/themes/_dark.yaml + install -Dm0644 ${ + ../tinted-theming/base16/albino-bark-on-a-tree.yaml + } ./data/foodogsquared-homepage/themes/_light.yaml ''; meta = with lib; { diff --git a/configs/home-manager/foo-dogsquared/files/homepage/shell.nix b/configs/home-manager/foo-dogsquared/files/homepage/shell.nix index 476048f5..70c8cfe8 100644 --- a/configs/home-manager/foo-dogsquared/files/homepage/shell.nix +++ b/configs/home-manager/foo-dogsquared/files/homepage/shell.nix @@ -1,14 +1,9 @@ -{ pkgs ? import { - overlays = [ (import ../../../../../overlays).default ]; -} }: +{ pkgs ? + import { overlays = [ (import ../../../../../overlays).default ]; } +}: -let - site = pkgs.callPackage ./package.nix { }; -in -pkgs.mkShell { +let site = pkgs.callPackage ./package.nix { }; +in pkgs.mkShell { inputsFrom = [ site ]; - packages = with pkgs; [ - treefmt - npins - ]; + packages = with pkgs; [ treefmt npins ]; } diff --git a/configs/home-manager/foo-dogsquared/modules/dotfiles.nix b/configs/home-manager/foo-dogsquared/modules/dotfiles.nix index daa49150..06380b05 100644 --- a/configs/home-manager/foo-dogsquared/modules/dotfiles.nix +++ b/configs/home-manager/foo-dogsquared/modules/dotfiles.nix @@ -7,10 +7,10 @@ let projectsDir = config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR; dotfiles = "${projectsDir}/packages/dotfiles"; - dotfiles' = config.lib.file.mkOutOfStoreSymlink config.home.mutableFile."${dotfiles}".path; + dotfiles' = config.lib.file.mkOutOfStoreSymlink + config.home.mutableFile."${dotfiles}".path; getDotfiles = path: "${dotfiles'}/${path}"; -in -{ +in { options.users.foo-dogsquared.dotfiles.enable = lib.mkEnableOption "custom outside dotfiles for other programs"; @@ -21,9 +21,7 @@ in type = "git"; }; - home.sessionPath = [ - "${config.home.mutableFile.${dotfiles}.path}/bin" - ]; + home.sessionPath = [ "${config.home.mutableFile.${dotfiles}.path}/bin" ]; } (lib.mkIf (userCfg.programs.doom-emacs.enable) { @@ -59,7 +57,8 @@ in }) (lib.mkIf config.programs.nushell.enable { - home.file."${config.xdg.dataHome}/nushell/vendor/autoload".source = getDotfiles "nu/autoload"; + home.file."${config.xdg.dataHome}/nushell/vendor/autoload".source = + getDotfiles "nu/autoload"; }) ]); } diff --git a/configs/home-manager/foo-dogsquared/modules/programs/browsers.nix b/configs/home-manager/foo-dogsquared/modules/programs/browsers.nix index 39be1ef2..9cea3941 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/browsers.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/browsers.nix @@ -23,13 +23,14 @@ let { id = "palihjnakafgffnompkdfgbgdbcagbko"; } # UpdateSWH { id = "gphhapmejobijbbhgpjhcjognlahblep"; } # GNOME Shell integration ]; -in -{ +in { options.users.foo-dogsquared.programs.browsers = { firefox.enable = lib.mkEnableOption "foo-dogsquared's Firefox setup"; brave.enable = lib.mkEnableOption "foo-dogsquared's Brave setup"; - google-chrome.enable = lib.mkEnableOption "foo-dogsquared's Google Chrome setup"; - misc.enable = lib.mkEnableOption "foo-dogsquared's miscellaneous browsers setup"; + google-chrome.enable = + lib.mkEnableOption "foo-dogsquared's Google Chrome setup"; + misc.enable = + lib.mkEnableOption "foo-dogsquared's miscellaneous browsers setup"; plugins.firenvim.enable = lib.mkEnableOption "setting up Firenvim"; }; @@ -39,10 +40,8 @@ in (lib.mkIf cfg.brave.enable { programs.brave = { enable = true; - commandLineArgs = [ - "--no-default-browser-check" - "--use-system-default-printer" - ]; + commandLineArgs = + [ "--no-default-browser-check" "--use-system-default-printer" ]; extensions = commonExtensions; }; @@ -63,71 +62,70 @@ in programs.firefox = { enable = true; - package = with pkgs; wrapFirefox firefox-unwrapped { - nativeMessagingHosts = with pkgs; [ - bukubrow - tridactyl-native - ] ++ lib.optional config.programs.mpv.enable pkgs.ff2mpv; + package = with pkgs; + wrapFirefox firefox-unwrapped { + nativeMessagingHosts = with pkgs; + [ bukubrow tridactyl-native ] + ++ lib.optional config.programs.mpv.enable pkgs.ff2mpv; - extraPolicies = { - AppAutoUpdate = false; - DisableAppUpdate = true; - DisableMasterPasswordCreation = true; - DisablePocket = true; - DisableSetDesktopBackground = true; - DontCheckDefaultBrowser = true; - EnableTrackingProtection = true; - FirefoxHome = { - Highlights = false; - Pocket = false; - Snippets = false; - SponsporedPocket = false; - SponsporedTopSites = false; + extraPolicies = { + AppAutoUpdate = false; + DisableAppUpdate = true; + DisableMasterPasswordCreation = true; + DisablePocket = true; + DisableSetDesktopBackground = true; + DontCheckDefaultBrowser = true; + EnableTrackingProtection = true; + FirefoxHome = { + Highlights = false; + Pocket = false; + Snippets = false; + SponsporedPocket = false; + SponsporedTopSites = false; + }; + NoDefaultBookmarks = true; + OfferToSaveLoginsDefault = false; + PasswordManagerEnabled = false; + SanitizeOnShutdown = { FormData = true; }; + UseSystemPrintDialog = true; }; - NoDefaultBookmarks = true; - OfferToSaveLoginsDefault = false; - PasswordManagerEnabled = false; - SanitizeOnShutdown = { - FormData = true; - }; - UseSystemPrintDialog = true; }; - }; profiles.personal = { isDefault = true; - extensions = with pkgs.nur.repos.rycee.firefox-addons; [ - aw-watcher-web - bitwarden - browserpass - facebook-container - firefox-color - firefox-translations - firenvim - languagetool - multi-account-containers - privacy-badger - search-by-image - tampermonkey - tridactyl - ublock-origin - vimium - wayback-machine - ] ++ (with pkgs.firefox-addons; [ - get-rss-feed-url - google-container - microsoft-container - regretsreporter - simple-translate - sourcegraph-for-firefox - tineye-reverse-image-search - updateswh - zhongwen - open-access-helper - rsshub-radar - ]) - ++ lib.optionals config.programs.mpv.enable (with pkgs.nur.repos.rycee.firefox-addons; [ ff2mpv ]); + extensions = with pkgs.nur.repos.rycee.firefox-addons; + [ + aw-watcher-web + bitwarden + browserpass + facebook-container + firefox-color + firefox-translations + firenvim + languagetool + multi-account-containers + privacy-badger + search-by-image + tampermonkey + tridactyl + ublock-origin + vimium + wayback-machine + ] ++ (with pkgs.firefox-addons; [ + get-rss-feed-url + google-container + microsoft-container + regretsreporter + simple-translate + sourcegraph-for-firefox + tineye-reverse-image-search + updateswh + zhongwen + open-access-helper + rsshub-radar + ]) ++ lib.optionals config.programs.mpv.enable + (with pkgs.nur.repos.rycee.firefox-addons; [ ff2mpv ]); # Much of the settings are affected by the policies set in the # package. See more information about them in @@ -140,7 +138,8 @@ in "browser.search.widget.inNavBar" = true; "browser.search.openintab" = true; "browser.startup.homepage" = - lib.mkIf userCfg.programs.custom-homepage.enable "file://${config.xdg.dataHome}/foodogsquared/homepage"; + lib.mkIf userCfg.programs.custom-homepage.enable + "file://${config.xdg.dataHome}/foodogsquared/homepage"; # Some privacy settings... "privacy.donottrackheader.enabled" = true; @@ -162,22 +161,25 @@ in search = { default = "Brave"; force = true; - order = [ - "Brave" - "Nix Packages" - "Google" - ]; + order = [ "Brave" "Nix Packages" "Google" ]; engines = { "Brave" = { urls = [{ template = "https://search.brave.com/search"; params = [ - { name = "type"; value = "search"; } - { name = "q"; value = "{searchTerms}"; } + { + name = "type"; + value = "search"; + } + { + name = "q"; + value = "{searchTerms}"; + } ]; }]; - icon = "${config.programs.brave.package}/share/icons/hicolor/64x64/apps/brave-browser.png"; + icon = + "${config.programs.brave.package}/share/icons/hicolor/64x64/apps/brave-browser.png"; definedAliases = [ "@brave" "@b" ]; }; @@ -185,12 +187,19 @@ in urls = [{ template = "https://search.nixos.org/packages"; params = [ - { name = "type"; value = "packages"; } - { name = "query"; value = "{searchTerms}"; } + { + name = "type"; + value = "packages"; + } + { + name = "query"; + value = "{searchTerms}"; + } ]; }]; - icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + icon = + "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; definedAliases = [ "@np" ]; }; @@ -239,10 +248,8 @@ in (lib.mkIf cfg.google-chrome.enable { programs.google-chrome.enable = true; - programs.google-chrome.commandLineArgs = [ - "--no-default-browser-check" - "--use-system-default-printer" - ]; + programs.google-chrome.commandLineArgs = + [ "--no-default-browser-check" "--use-system-default-printer" ]; services.bleachbit.cleaners = [ "google_chrome.cookies" @@ -257,30 +264,19 @@ in }) # Goes with whatever you want to. - (lib.mkIf cfg.misc.enable { - home.packages = with pkgs; [ - nyxt - ]; - }) + (lib.mkIf cfg.misc.enable { home.packages = with pkgs; [ nyxt ]; }) - (lib.mkIf cfg.plugins.firenvim.enable - (let - supportedBrowsers = [ - "brave" - "chromium" - "google-chrome" - "vivaldi" - ]; - enableSupportedBrowser = acc: name: acc // { - programs.${name}.extensions = [ - { id = "egpjdkipkomnmjhjmdamaniclmdlobbo"; } - ]; + (lib.mkIf cfg.plugins.firenvim.enable (let + supportedBrowsers = [ "brave" "chromium" "google-chrome" "vivaldi" ]; + enableSupportedBrowser = acc: name: + acc // { + programs.${name}.extensions = + [{ id = "egpjdkipkomnmjhjmdamaniclmdlobbo"; }]; }; - in - lib.foldl' enableSupportedBrowser { } supportedBrowsers // { - programs.firefox.profiles.personal.extensions = with pkgs.nur.repos.rycee.firefox-addons; [ - firenvim - ]; - })) + in lib.foldl' enableSupportedBrowser { } supportedBrowsers // { + programs.firefox.profiles.personal.extensions = + with pkgs.nur.repos.rycee.firefox-addons; + [ firenvim ]; + })) ]; } diff --git a/configs/home-manager/foo-dogsquared/modules/programs/custom-homepage.nix b/configs/home-manager/foo-dogsquared/modules/programs/custom-homepage.nix index 5d52fbdf..c2a5c0ce 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/custom-homepage.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/custom-homepage.nix @@ -6,8 +6,7 @@ let settingsFormat = pkgs.formats.toml { }; themesSettingsFormat = pkgs.formats.yaml { }; -in -{ +in { options.users.foo-dogsquared.programs.custom-homepage = { enable = lib.mkEnableOption "addition of custom homepage"; @@ -97,27 +96,26 @@ in }; config = { - users.foo-dogsquared.programs.custom-homepage.finalPackage = - let - data = lib.mapAttrs (n: v: - settingsFormat.generate "fds-homepage-section-${n}" v) cfg.sections; + users.foo-dogsquared.programs.custom-homepage.finalPackage = let + data = lib.mapAttrs + (n: v: settingsFormat.generate "fds-homepage-section-${n}" v) + cfg.sections; - installDataDir = lib.foldlAttrs (acc: n: v: '' - ${acc} - install -Dm0644 ${v} './data/foodogsquared-homepage/links/${n}.toml' - '') "" data; + installDataDir = lib.foldlAttrs (acc: n: v: '' + ${acc} + install -Dm0644 ${v} './data/foodogsquared-homepage/links/${n}.toml' + '') "" data; - installThemes = lib.foldlAttrs (acc: n: v: '' - ${acc} - install -Dm0644 ${v} './data/foodogsquared-homepage/themes/${n}}.yaml - '') "" cfg.themes; - in - cfg.package.overrideAttrs (prevAttrs: { - preBuild = (prevAttrs.preBuild or "") + '' - ${installDataDir} - ${installThemes} - ''; - }); + installThemes = lib.foldlAttrs (acc: n: v: '' + ${acc} + install -Dm0644 ${v} './data/foodogsquared-homepage/themes/${n}}.yaml + '') "" cfg.themes; + in cfg.package.overrideAttrs (prevAttrs: { + preBuild = (prevAttrs.preBuild or "") + '' + ${installDataDir} + ${installThemes} + ''; + }); xdg.dataFile."foodogsquared/homepage".source = cfg.finalPackage; }; diff --git a/configs/home-manager/foo-dogsquared/modules/programs/dconf.nix b/configs/home-manager/foo-dogsquared/modules/programs/dconf.nix index ea9fa4b2..bd569e16 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/dconf.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/dconf.nix @@ -4,8 +4,7 @@ let inherit (config.xdg) userDirs; userCfg = config.users.foo-dogsquared; cfg = userCfg.programs.dconf; -in -{ +in { options.users.foo-dogsquared.programs.dconf.enable = lib.mkEnableOption "dconf configuration"; @@ -13,10 +12,11 @@ in dconf.settings = { # My GNOME Shell and programs configuration. "org/gnome/shell" = { - favorite-apps = - lib.optional userCfg.programs.browsers.firefox.enable "firefox.desktop" + favorite-apps = lib.optional userCfg.programs.browsers.firefox.enable + "firefox.desktop" ++ lib.optional userCfg.setups.desktop.enable "thunderbird.desktop" - ++ lib.optional userCfg.setups.development.enable "org.wezfurlong.wezterm.desktop" + ++ lib.optional userCfg.setups.development.enable + "org.wezfurlong.wezterm.desktop" ++ lib.optional userCfg.programs.doom-emacs.enable "emacs.desktop" ++ lib.optional userCfg.programs.vs-code.enable "code.desktop"; }; diff --git a/configs/home-manager/foo-dogsquared/modules/programs/doom-emacs.nix b/configs/home-manager/foo-dogsquared/modules/programs/doom-emacs.nix index 426eb437..f94b0fe9 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/doom-emacs.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/doom-emacs.nix @@ -9,8 +9,7 @@ let cfg = userCfg.programs.doom-emacs; doomEmacsInstallation = "${config.xdg.configHome}/emacs"; -in -{ +in { options.users.foo-dogsquared.programs.doom-emacs.enable = lib.mkEnableOption "foo-dogsquared's Doom Emacs configuration"; @@ -18,12 +17,13 @@ in programs.emacs = { enable = true; package = pkgs.emacs; - extraPackages = epkgs: with epkgs; [ - org-noter-pdftools - org-pdftools - pdf-tools - vterm - ]; + extraPackages = epkgs: + with epkgs; [ + org-noter-pdftools + org-pdftools + pdf-tools + vterm + ]; }; # Automatically install Doom Emacs from here. @@ -58,16 +58,13 @@ in # :lang org +roam2 texlive.combined.scheme-medium sqlite - anystyle-cli + #anystyle-cli ]; programs.python = { enable = true; package = pkgs.python3; - modules = ps: with ps; [ - jupyter - jupyter-book - ]; + modules = ps: with ps; [ jupyter jupyter-book ]; }; # Enable Emacs server for them quicknotes. diff --git a/configs/home-manager/foo-dogsquared/modules/programs/email.nix b/configs/home-manager/foo-dogsquared/modules/programs/email.nix index 54100699..21500365 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/email.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/email.nix @@ -8,7 +8,8 @@ let address = "${name}@${domain}"; userName = "${name}@${domain}"; realName = lib.mkDefault "${name}@${domain}"; - passwordCommand = lib.mkDefault "gopass show email/${domain}/${name} | head -n 1"; + passwordCommand = + lib.mkDefault "gopass show email/${domain}/${name} | head -n 1"; imap = { host = "heracles.mxrouting.net"; @@ -23,11 +24,11 @@ let tls.enable = true; }; }; -in -{ +in { options.users.foo-dogsquared.programs.email = { enable = lib.mkEnableOption "foo-dogsquared's email setup"; - thunderbird.enable = lib.mkEnableOption "foo-dogsquared's Thunderbird configuration"; + thunderbird.enable = + lib.mkEnableOption "foo-dogsquared's Thunderbird configuration"; }; config = lib.mkIf cfg.enable (lib.mkMerge [ @@ -64,7 +65,8 @@ in realName = config.accounts.email.accounts.personal.realName; userName = "foo.dogsquared@gmail.com"; flavor = "gmail.com"; - passwordCommand = "gopass show websites/accounts.google.com/foo.dogsquared | head -n 1"; + passwordCommand = + "gopass show websites/accounts.google.com/foo.dogsquared | head -n 1"; }; }; } diff --git a/configs/home-manager/foo-dogsquared/modules/programs/git.nix b/configs/home-manager/foo-dogsquared/modules/programs/git.nix index da2ba52c..825857d7 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/git.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/git.nix @@ -3,106 +3,104 @@ let userCfg = config.users.foo-dogsquared; cfg = userCfg.programs.git; -in -{ +in { options.users.foo-dogsquared.programs.git = { enable = lib.mkEnableOption "foo-dogsquared's Git setup"; - instaweb.enable = lib.mkEnableOption "install additional files for instaweb setup"; + instaweb.enable = + lib.mkEnableOption "install additional files for instaweb setup"; }; - config = lib.mkIf cfg.enable ( - lib.mkMerge [ - { - home.packages = with pkgs; [ - mergiraf # Merging giraffes are no small task. - tea # So you don't have to see some teas, I guess. - hut # So you don't have to see Sourcehut's brutalist design, I guess. - ]; + config = lib.mkIf cfg.enable (lib.mkMerge [ + { + home.packages = with pkgs; [ + mergiraf # Merging giraffes are no small task. + tea # So you don't have to see some teas, I guess. + hut # So you don't have to see Sourcehut's brutalist design, I guess. + ]; - # My Git credentials. - programs.git = { - enable = true; - package = pkgs.gitFull; - lfs.enable = true; - signing.key = "4AA9CDFF7C99DFF9"; - extraConfig = { - core.excludesFile = builtins.toString ../../config/git/ignore; + # My Git credentials. + programs.git = { + enable = true; + package = pkgs.gitFull; + lfs.enable = true; + signing.key = "4AA9CDFF7C99DFF9"; + extraConfig = { + core.excludesFile = builtins.toString ../../config/git/ignore; - user = { - name = config.accounts.email.accounts.personal.realName; - email = config.accounts.email.accounts.personal.address; - }; + user = { + name = config.accounts.email.accounts.personal.realName; + email = config.accounts.email.accounts.personal.address; + }; - alias = { - unstage = "reset HEAD --"; - quick-rebase = "rebase --interactive --autostash --committer-date-is-author-date"; - quick-clone = "clone --depth=1 --recurse-submodules --shallow-submodules"; - }; + alias = { + unstage = "reset HEAD --"; + quick-rebase = + "rebase --interactive --autostash --committer-date-is-author-date"; + quick-clone = + "clone --depth=1 --recurse-submodules --shallow-submodules"; + }; - init.defaultBranch = "main"; + init.defaultBranch = "main"; - # Shorthand for popular forges ala-Nix flake URL inputs. It's just a fun - # little part of the config. - url = { - "https://github.com/".insteadOf = [ "gh:" "github:" ]; - "https://gitlab.com/".insteadOf = [ "gl:" "gitlab:" ]; - "https://gitlab.gnome.org/".insteadOf = [ "gnome:" ]; - "https://invent.kde.org/".insteadOf = [ "kde:" ]; - "https://git.sr.ht/".insteadOf = [ "sh:" "sourcehut:" ]; - "https://git.savannah.nongnu.org/git/".insteadOf = [ "sv:" "savannah:" ]; - }; + # Shorthand for popular forges ala-Nix flake URL inputs. It's just a fun + # little part of the config. + url = { + "https://github.com/".insteadOf = [ "gh:" "github:" ]; + "https://gitlab.com/".insteadOf = [ "gl:" "gitlab:" ]; + "https://gitlab.gnome.org/".insteadOf = [ "gnome:" ]; + "https://invent.kde.org/".insteadOf = [ "kde:" ]; + "https://git.sr.ht/".insteadOf = [ "sh:" "sourcehut:" ]; + "https://git.savannah.nongnu.org/git/".insteadOf = + [ "sv:" "savannah:" ]; + }; - pull.rebase = "interactive"; + pull.rebase = "interactive"; - status = { - showPatch = true; - showStash = true; - }; + status = { + showPatch = true; + showStash = true; + }; - submodule.fetchJobs = 0; + submodule.fetchJobs = 0; + }; + }; + + # So you don't have to use GitHub, I guess. + programs.gh = { + enable = true; + extensions = with pkgs; [ gh-eco gh-dash gh-actions-cache ]; + + settings = { + git_protocol = "ssh"; + prompt = "enabled"; + + aliases = { + pc = "pr checkout"; + pv = "pr view"; }; }; + }; + } - # So you don't have to use GitHub, I guess. - programs.gh = { - enable = true; - extensions = with pkgs; [ - gh-eco - gh-dash - gh-actions-cache - ]; + (lib.mkIf cfg.instaweb.enable { + state.ports.git-instaweb.value = 15432; - settings = { - git_protocol = "ssh"; - prompt = "enabled"; + home.packages = with pkgs; [ lighttpd ]; - aliases = { - pc = "pr checkout"; - pv = "pr view"; - }; - }; - }; - } + programs.git.extraConfig.instaweb = { + local = true; + httpd = "lighttpd"; + port = config.state.ports.git-instaweb.value; + }; - (lib.mkIf cfg.instaweb.enable { - state.ports.git-instaweb.value = 15432; - - home.packages = with pkgs; [ - lighttpd - ]; - - programs.git.extraConfig.instaweb = { - local = true; - httpd = "lighttpd"; - port = config.state.ports.git-instaweb.value; - }; - - users.foo-dogsquared.programs.custom-homepage.sections.quicklinks.links = - lib.mkBefore (lib.singleton { - text = "Current git repo"; - url = "http://localhost:${builtins.toString config.state.ports.git-instaweb.value}"; - }); - }) - ]); + users.foo-dogsquared.programs.custom-homepage.sections.quicklinks.links = + lib.mkBefore (lib.singleton { + text = "Current git repo"; + url = "http://localhost:${ + builtins.toString config.state.ports.git-instaweb.value + }"; + }); + }) + ]); } diff --git a/configs/home-manager/foo-dogsquared/modules/programs/hledger.nix b/configs/home-manager/foo-dogsquared/modules/programs/hledger.nix index ed43067c..2d90b771 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/hledger.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/hledger.nix @@ -3,17 +3,11 @@ let userCfg = config.users.foo-dogsquared; cfg = userCfg.programs.hledger; -in -{ +in { options.users.foo-dogsquared.programs.hledger.enable = lib.mkEnableOption "hledger setup"; config = lib.mkIf cfg.enable { - home.packages = with pkgs; [ - hledger - hledger-ui - hledger-web - hledger-utils - ]; + home.packages = with pkgs; [ hledger hledger-ui hledger-web hledger-utils ]; }; } diff --git a/configs/home-manager/foo-dogsquared/modules/programs/jujutsu.nix b/configs/home-manager/foo-dogsquared/modules/programs/jujutsu.nix index f154ea51..d76d6a1a 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/jujutsu.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/jujutsu.nix @@ -3,8 +3,7 @@ let userCfg = config.users.foo-dogsquared; cfg = userCfg.programs.jujutsu; -in -{ +in { options.users.foo-dogsquared.programs.jujutsu.enable = lib.mkEnableOption "foo-dogsquared's Jujutsu configuration"; diff --git a/configs/home-manager/foo-dogsquared/modules/programs/keys.nix b/configs/home-manager/foo-dogsquared/modules/programs/keys.nix index d0fe9298..953ce8fc 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/keys.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/keys.nix @@ -3,8 +3,7 @@ let userCfg = config.users.foo-dogsquared; cfg = userCfg.programs.keys; -in -{ +in { options.users.foo-dogsquared.programs.keys = { ssh.enable = lib.mkEnableOption "foo-dogsquared's SSH config"; gpg.enable = lib.mkEnableOption "foo-dogsquared's GPG config"; diff --git a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/colorschemes.nix b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/colorschemes.nix index ea8da3cb..6dfd7967 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/colorschemes.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/colorschemes.nix @@ -9,12 +9,12 @@ let ''; sym = query: ''sym("${query}")''; -in -{ +in { colorscheme = - if config.bahaghari.tinted-theming.schemes?"bark-on-a-tree" - then (lib.mkForce "bark-on-a-tree") - else (lib.mkDefault "default"); + if config.bahaghari.tinted-theming.schemes ? "bark-on-a-tree" then + (lib.mkForce "bark-on-a-tree") + else + (lib.mkDefault "default"); colorschemes.lush = { enable = true; @@ -23,343 +23,526 @@ in local hsl = lush.hsl local hsluv = lush.hsluv ''; - themes = - lib.mapAttrs - (name: metadata: { - extraConfigLua = '' - ${lib.foldlAttrs initLushBase16 "" metadata.palette} + themes = lib.mapAttrs (name: metadata: { + extraConfigLua = '' + ${lib.foldlAttrs initLushBase16 "" metadata.palette} - -- Set the background. - vim.o.background = '${metadata.variant}' + -- Set the background. + vim.o.background = '${metadata.variant}' - vim.g.terminal_color_0 = base00.hex - vim.g.terminal_color_1 = base08.hex - vim.g.terminal_color_2 = base0B.hex - vim.g.terminal_color_3 = base0A.hex - vim.g.terminal_color_4 = base0D.hex - vim.g.terminal_color_5 = base0E.hex - vim.g.terminal_color_6 = base0C.hex - vim.g.terminal_color_7 = base05.hex - vim.g.terminal_color_8 = base03.hex - vim.g.terminal_color_9 = base08.hex - vim.g.terminal_color_10 = base0B.hex - vim.g.terminal_color_11 = base0A.hex - vim.g.terminal_color_12 = base0D.hex - vim.g.terminal_color_13 = base0E.hex - vim.g.terminal_color_14 = base0C.hex - vim.g.terminal_color_15 = base07.hex - vim.g.terminal_color_background = base00.hex - vim.g.terminal_color_foreground = base0E.hex - ''; + vim.g.terminal_color_0 = base00.hex + vim.g.terminal_color_1 = base08.hex + vim.g.terminal_color_2 = base0B.hex + vim.g.terminal_color_3 = base0A.hex + vim.g.terminal_color_4 = base0D.hex + vim.g.terminal_color_5 = base0E.hex + vim.g.terminal_color_6 = base0C.hex + vim.g.terminal_color_7 = base05.hex + vim.g.terminal_color_8 = base03.hex + vim.g.terminal_color_9 = base08.hex + vim.g.terminal_color_10 = base0B.hex + vim.g.terminal_color_11 = base0A.hex + vim.g.terminal_color_12 = base0D.hex + vim.g.terminal_color_13 = base0E.hex + vim.g.terminal_color_14 = base0C.hex + vim.g.terminal_color_15 = base07.hex + vim.g.terminal_color_background = base00.hex + vim.g.terminal_color_foreground = base0E.hex + ''; - highlights = lib.mkMerge [ - rec { - Normal = { fg = mkRaw "base05"; bg = mkRaw "base00"; }; - NormalFloat = { - fg = mkRaw "Normal.fg.saturate(15).lighten(5)"; - bg = mkRaw "Normal.bg.saturate(15).lighten(5)"; - }; - Bold.gui = "bold"; - Debug.fg = mkRaw "base08"; - Directory.fg = mkRaw "base0D"; - Error = { fg = mkRaw "base01"; bg = mkRaw "base08"; }; - ErrorMsg.fg = mkRaw "base08"; - Exception.fg = mkRaw "base08"; - FoldColumn.fg = mkRaw "base03"; - Folded = { - fg = mkRaw "base03"; - bg = mkRaw "base01"; - }; - Italic.gui = "italic"; - Macro.fg = mkRaw "base08"; - ModeMsg.fg = mkRaw "base0B"; - MoreMsg.fg = mkRaw "base0B"; - Question.fg = mkRaw "base0D"; - Search = { - fg = mkRaw "base00"; - bg = mkRaw "base04"; - }; - IncSearch = { - fg = mkRaw "base00"; - bg = mkRaw "base09"; - }; - Substitute = { - fg = mkRaw "base01"; - bg = mkRaw "base0A"; - }; + highlights = lib.mkMerge [ + rec { + Normal = { + fg = mkRaw "base05"; + bg = mkRaw "base00"; + }; + NormalFloat = { + fg = mkRaw "Normal.fg.saturate(15).lighten(5)"; + bg = mkRaw "Normal.bg.saturate(15).lighten(5)"; + }; + Bold.gui = "bold"; + Debug.fg = mkRaw "base08"; + Directory.fg = mkRaw "base0D"; + Error = { + fg = mkRaw "base01"; + bg = mkRaw "base08"; + }; + ErrorMsg.fg = mkRaw "base08"; + Exception.fg = mkRaw "base08"; + FoldColumn.fg = mkRaw "base03"; + Folded = { + fg = mkRaw "base03"; + bg = mkRaw "base01"; + }; + Italic.gui = "italic"; + Macro.fg = mkRaw "base08"; + ModeMsg.fg = mkRaw "base0B"; + MoreMsg.fg = mkRaw "base0B"; + Question.fg = mkRaw "base0D"; + Search = { + fg = mkRaw "base00"; + bg = mkRaw "base04"; + }; + IncSearch = { + fg = mkRaw "base00"; + bg = mkRaw "base09"; + }; + Substitute = { + fg = mkRaw "base01"; + bg = mkRaw "base0A"; + }; - TooLong.fg = mkRaw "base08"; - Underlined = { fg = mkRaw "base08"; }; - WarningMsg = { fg = mkRaw "base08"; }; - WildMenu = { fg = mkRaw "base08"; bg = mkRaw "base0A"; }; - Title.fg = mkRaw "base0D"; - Conceal.fg = mkRaw "base0D"; - Cursor = { fg = mkRaw "base00"; bg = mkRaw "base05"; }; - NonText = { fg = mkRaw "base03"; }; - LineNr = { fg = mkRaw "base02.lighten(25)"; bg = mkRaw "base00"; }; - LineNrNC = { fg = mkRaw "base02.lighten(25)"; bg = mkRaw "base01"; }; - SignColumn = { fg = mkRaw "base01.lighten(40)"; }; - StatusLine = { fg = mkRaw "base02"; bg = mkRaw "base01.darken(60)"; }; - StatusLineNC = { fg = mkRaw "base02"; bg = mkRaw "base01.darken(30)"; }; - VertSplit = { fg = mkRaw "base02"; bg = mkRaw "base00"; }; - ColorColumn = { fg = mkRaw "base01.lighten(25)"; bg = mkRaw "base01.darken(25)"; }; - CursorLine = { bg = mkRaw "base01.saturate(-5).darken(15)"; }; - CursorColumn = CursorLine; - CursorLineNr.fg = mkRaw "base0A"; - Visual = { - fg = mkRaw "base03.lighten(15)"; - bg = mkRaw "CursorColumn.bg.darken(15)"; - }; - VisualNOS = { fg = mkRaw "base08"; }; - QuickFixLine = { bg = mkRaw "base00"; }; - QFFileName = { fg = mkRaw "base0A"; }; - QFLineNr = { fg = mkRaw "base04"; }; - PMenu = { fg = mkRaw "base05"; bg = mkRaw "base01"; }; - PMenuSel = { fg = mkRaw "base01"; bg = mkRaw "base05"; }; - TabLineSel = { fg = mkRaw "base00"; bg = mkRaw "base0A"; }; - TabLine = { fg = mkRaw "base03"; bg = mkRaw "base00.darken(15)"; }; - TabLineFill = { fg = mkRaw "base03"; bg = mkRaw "base00.darken(25)"; }; - EndOfBuffer = { fg = mkRaw "base01.lighten(20)"; bg = mkRaw "base01.darken(20)"; }; + TooLong.fg = mkRaw "base08"; + Underlined = { fg = mkRaw "base08"; }; + WarningMsg = { fg = mkRaw "base08"; }; + WildMenu = { + fg = mkRaw "base08"; + bg = mkRaw "base0A"; + }; + Title.fg = mkRaw "base0D"; + Conceal.fg = mkRaw "base0D"; + Cursor = { + fg = mkRaw "base00"; + bg = mkRaw "base05"; + }; + NonText = { fg = mkRaw "base03"; }; + LineNr = { + fg = mkRaw "base02.lighten(25)"; + bg = mkRaw "base00"; + }; + LineNrNC = { + fg = mkRaw "base02.lighten(25)"; + bg = mkRaw "base01"; + }; + SignColumn = { fg = mkRaw "base01.lighten(40)"; }; + StatusLine = { + fg = mkRaw "base02"; + bg = mkRaw "base01.darken(60)"; + }; + StatusLineNC = { + fg = mkRaw "base02"; + bg = mkRaw "base01.darken(30)"; + }; + VertSplit = { + fg = mkRaw "base02"; + bg = mkRaw "base00"; + }; + ColorColumn = { + fg = mkRaw "base01.lighten(25)"; + bg = mkRaw "base01.darken(25)"; + }; + CursorLine = { bg = mkRaw "base01.saturate(-5).darken(15)"; }; + CursorColumn = CursorLine; + CursorLineNr.fg = mkRaw "base0A"; + Visual = { + fg = mkRaw "base03.lighten(15)"; + bg = mkRaw "CursorColumn.bg.darken(15)"; + }; + VisualNOS = { fg = mkRaw "base08"; }; + QuickFixLine = { bg = mkRaw "base00"; }; + QFFileName = { fg = mkRaw "base0A"; }; + QFLineNr = { fg = mkRaw "base04"; }; + PMenu = { + fg = mkRaw "base05"; + bg = mkRaw "base01"; + }; + PMenuSel = { + fg = mkRaw "base01"; + bg = mkRaw "base05"; + }; + TabLineSel = { + fg = mkRaw "base00"; + bg = mkRaw "base0A"; + }; + TabLine = { + fg = mkRaw "base03"; + bg = mkRaw "base00.darken(15)"; + }; + TabLineFill = { + fg = mkRaw "base03"; + bg = mkRaw "base00.darken(25)"; + }; + EndOfBuffer = { + fg = mkRaw "base01.lighten(20)"; + bg = mkRaw "base01.darken(20)"; + }; - # Standard syntax highlighting - Boolean = { fg = mkRaw "base09"; }; - Character = { fg = mkRaw "base08"; }; - Comment = { fg = mkRaw "base03"; gui = "italic"; }; - Conditional = { fg = mkRaw "base0E"; }; - Constant = { fg = mkRaw "base09"; }; - Define = { fg = mkRaw "base0E"; }; - Delimiter = { fg = mkRaw "base0F.lighten(10)"; }; - Float = { fg = mkRaw "base09"; }; - Function = { fg = mkRaw "base0D"; }; - Identifier = { fg = mkRaw "base0A"; }; - Include = { fg = mkRaw "base0D"; }; - Keyword = { fg = mkRaw "base0E"; }; - Label = { fg = mkRaw "base0A"; }; - Number = { fg = mkRaw "base03"; }; - Operator = { fg = mkRaw "base03"; }; - PreProc = { fg = mkRaw "base0A"; }; - Repeat = { fg = mkRaw "base0A"; }; - Special = { fg = mkRaw "base0C"; }; - SpecialChar = { fg = mkRaw "base0F.lighten(15).saturate(10)"; }; - Statement = { fg = mkRaw "base08"; }; - StorageClass = { fg = mkRaw "base0A"; }; - String = { fg = mkRaw "base0B"; }; - Structure = { fg = mkRaw "base0E"; }; - Tag = { fg = mkRaw "base0A"; }; - Todo = { fg = mkRaw "base0A"; bg = mkRaw "base01"; }; - Type = { fg = mkRaw "base0A"; }; - Typedef = { fg = mkRaw "base0A"; }; + # Standard syntax highlighting + Boolean = { fg = mkRaw "base09"; }; + Character = { fg = mkRaw "base08"; }; + Comment = { + fg = mkRaw "base03"; + gui = "italic"; + }; + Conditional = { fg = mkRaw "base0E"; }; + Constant = { fg = mkRaw "base09"; }; + Define = { fg = mkRaw "base0E"; }; + Delimiter = { fg = mkRaw "base0F.lighten(10)"; }; + Float = { fg = mkRaw "base09"; }; + Function = { fg = mkRaw "base0D"; }; + Identifier = { fg = mkRaw "base0A"; }; + Include = { fg = mkRaw "base0D"; }; + Keyword = { fg = mkRaw "base0E"; }; + Label = { fg = mkRaw "base0A"; }; + Number = { fg = mkRaw "base03"; }; + Operator = { fg = mkRaw "base03"; }; + PreProc = { fg = mkRaw "base0A"; }; + Repeat = { fg = mkRaw "base0A"; }; + Special = { fg = mkRaw "base0C"; }; + SpecialChar = { fg = mkRaw "base0F.lighten(15).saturate(10)"; }; + Statement = { fg = mkRaw "base08"; }; + StorageClass = { fg = mkRaw "base0A"; }; + String = { fg = mkRaw "base0B"; }; + Structure = { fg = mkRaw "base0E"; }; + Tag = { fg = mkRaw "base0A"; }; + Todo = { + fg = mkRaw "base0A"; + bg = mkRaw "base01"; + }; + Type = { fg = mkRaw "base0A"; }; + Typedef = { fg = mkRaw "base0A"; }; - # Help - HelpDoc = { fg = mkRaw "base05"; bg = mkRaw "base0D"; gui = "bold;italic"; }; - HelpIgnore = { fg = mkRaw "base0B"; gui = "bold;italic"; }; + # Help + HelpDoc = { + fg = mkRaw "base05"; + bg = mkRaw "base0D"; + gui = "bold;italic"; + }; + HelpIgnore = { + fg = mkRaw "base0B"; + gui = "bold;italic"; + }; - # C highlighting - cOperator = { fg = mkRaw "base0C"; }; - cPreCondit = { fg = mkRaw "base0E"; }; + # C highlighting + cOperator = { fg = mkRaw "base0C"; }; + cPreCondit = { fg = mkRaw "base0E"; }; - # C# highlighting - csClass = { fg = mkRaw "base0A"; }; - csAttribute = { fg = mkRaw "base0A"; }; - csModifier = { fg = mkRaw "base0E"; }; - csType = { fg = mkRaw "base08"; }; - csUnspecifiedStatement = { fg = mkRaw "base0D"; }; - csContextualStatement = { fg = mkRaw "base0E"; }; - csNewDecleration = { fg = mkRaw "base08"; }; + # C# highlighting + csClass = { fg = mkRaw "base0A"; }; + csAttribute = { fg = mkRaw "base0A"; }; + csModifier = { fg = mkRaw "base0E"; }; + csType = { fg = mkRaw "base08"; }; + csUnspecifiedStatement = { fg = mkRaw "base0D"; }; + csContextualStatement = { fg = mkRaw "base0E"; }; + csNewDecleration = { fg = mkRaw "base08"; }; - # CSS highlighting - cssBraces = { fg = mkRaw "base05"; }; - cssClassName = { fg = mkRaw "base0E"; }; - cssColor = { fg = mkRaw "base0C"; }; + # CSS highlighting + cssBraces = { fg = mkRaw "base05"; }; + cssClassName = { fg = mkRaw "base0E"; }; + cssColor = { fg = mkRaw "base0C"; }; - # Diff highlighting - DiffAdd = { fg = mkRaw "base0B"; bg = mkRaw "base0B.darken(80)"; }; - DiffAdded = { fg = mkRaw "base0B"; bg = mkRaw "base0B.darken(80)"; }; - DiffNewFile = { fg = mkRaw "base0B"; bg = mkRaw "base0B.darken(80)"; }; + # Diff highlighting + DiffAdd = { + fg = mkRaw "base0B"; + bg = mkRaw "base0B.darken(80)"; + }; + DiffAdded = { + fg = mkRaw "base0B"; + bg = mkRaw "base0B.darken(80)"; + }; + DiffNewFile = { + fg = mkRaw "base0B"; + bg = mkRaw "base0B.darken(80)"; + }; - DiffDelete = { fg = mkRaw "base08"; bg = mkRaw "base08.darken(80)"; }; - DiffRemoved = { fg = mkRaw "base08"; bg = mkRaw "base08.darken(80)"; }; + DiffDelete = { + fg = mkRaw "base08"; + bg = mkRaw "base08.darken(80)"; + }; + DiffRemoved = { + fg = mkRaw "base08"; + bg = mkRaw "base08.darken(80)"; + }; - DiffChange = { fg = mkRaw "base03"; bg = mkRaw "base03.darken(60)"; }; - DiffFile = { fg = mkRaw "base03"; bg = mkRaw "base03.darken(60)"; }; - DiffLine = { fg = mkRaw "base03"; bg = mkRaw "base03.darken(60)"; }; - DiffText = { fg = mkRaw "base03"; bg = mkRaw "base03.darken(60)"; }; + DiffChange = { + fg = mkRaw "base03"; + bg = mkRaw "base03.darken(60)"; + }; + DiffFile = { + fg = mkRaw "base03"; + bg = mkRaw "base03.darken(60)"; + }; + DiffLine = { + fg = mkRaw "base03"; + bg = mkRaw "base03.darken(60)"; + }; + DiffText = { + fg = mkRaw "base03"; + bg = mkRaw "base03.darken(60)"; + }; - # Git highlighting - gitcommitOverflow = { fg = mkRaw "base08"; }; - gitcommitSummary = { fg = mkRaw "base0B"; }; - gitcommitComment = { fg = mkRaw "base03"; }; - gitcommitUntracked = { fg = mkRaw "base03"; }; - gitcommitDiscarded = { fg = mkRaw "base03"; }; - gitcommitSelected = { fg = mkRaw "base03"; }; - gitcommitHeader = { fg = mkRaw "base0E"; }; - gitcommitSelectedType = { fg = mkRaw "base0D"; }; - gitcommitUnmergedType = { fg = mkRaw "base0D"; }; - gitcommitDiscardedType = { fg = mkRaw "base0D"; }; - gitcommitBranch = { fg = mkRaw "base09"; gui = "bold"; }; - gitcommitUntrackedFile = { fg = mkRaw "base0A"; }; - gitcommitUnmergedFile = { fg = mkRaw "base08"; gui = "bold"; }; - gitcommitDiscardedFile = { fg = mkRaw "base08"; gui = "bold"; }; - gitcommitSelectedFile = { fg = mkRaw "base0B"; gui = "bold"; }; + # Git highlighting + gitcommitOverflow = { fg = mkRaw "base08"; }; + gitcommitSummary = { fg = mkRaw "base0B"; }; + gitcommitComment = { fg = mkRaw "base03"; }; + gitcommitUntracked = { fg = mkRaw "base03"; }; + gitcommitDiscarded = { fg = mkRaw "base03"; }; + gitcommitSelected = { fg = mkRaw "base03"; }; + gitcommitHeader = { fg = mkRaw "base0E"; }; + gitcommitSelectedType = { fg = mkRaw "base0D"; }; + gitcommitUnmergedType = { fg = mkRaw "base0D"; }; + gitcommitDiscardedType = { fg = mkRaw "base0D"; }; + gitcommitBranch = { + fg = mkRaw "base09"; + gui = "bold"; + }; + gitcommitUntrackedFile = { fg = mkRaw "base0A"; }; + gitcommitUnmergedFile = { + fg = mkRaw "base08"; + gui = "bold"; + }; + gitcommitDiscardedFile = { + fg = mkRaw "base08"; + gui = "bold"; + }; + gitcommitSelectedFile = { + fg = mkRaw "base0B"; + gui = "bold"; + }; - # HTML highlighting - htmlBold = { fg = mkRaw "base0A"; }; - htmlItalic = { fg = mkRaw "base0E"; }; - htmlEndTag = { fg = mkRaw "base05"; }; - htmlTag = { fg = mkRaw "base05"; }; + # HTML highlighting + htmlBold = { fg = mkRaw "base0A"; }; + htmlItalic = { fg = mkRaw "base0E"; }; + htmlEndTag = { fg = mkRaw "base05"; }; + htmlTag = { fg = mkRaw "base05"; }; - # JavaScript highlighting - javaScript = { fg = mkRaw "base05"; }; - javaScriptBraces = { fg = mkRaw "base05"; }; - javaScriptNumber = { fg = mkRaw "base09"; }; + # JavaScript highlighting + javaScript = { fg = mkRaw "base05"; }; + javaScriptBraces = { fg = mkRaw "base05"; }; + javaScriptNumber = { fg = mkRaw "base09"; }; - # pangloss/vim-javascript highlighting - jsOperator = { fg = mkRaw "base0D"; }; - jsStatement = { fg = mkRaw "base0E"; }; - jsReturn = { fg = mkRaw "base0E"; }; - jsThis = { fg = mkRaw "base08"; }; - jsClassDefinition = { fg = mkRaw "base0A"; }; - jsFunction = { fg = mkRaw "base0E"; }; - jsFuncName = { fg = mkRaw "base0D"; }; - jsFuncCall = { fg = mkRaw "base0D"; }; - jsClassFuncName = { fg = mkRaw "base0D"; }; - jsClassMethodType = { fg = mkRaw "base0E"; }; - jsRegexpString = { fg = mkRaw "base0C"; }; - jsGlobalObjects = { fg = mkRaw "base0A"; }; - jsGlobalNodeObjects = { fg = mkRaw "base0A"; }; - jsExceptions = { fg = mkRaw "base0A"; }; - jsBuiltins = { fg = mkRaw "base0A"; }; + # pangloss/vim-javascript highlighting + jsOperator = { fg = mkRaw "base0D"; }; + jsStatement = { fg = mkRaw "base0E"; }; + jsReturn = { fg = mkRaw "base0E"; }; + jsThis = { fg = mkRaw "base08"; }; + jsClassDefinition = { fg = mkRaw "base0A"; }; + jsFunction = { fg = mkRaw "base0E"; }; + jsFuncName = { fg = mkRaw "base0D"; }; + jsFuncCall = { fg = mkRaw "base0D"; }; + jsClassFuncName = { fg = mkRaw "base0D"; }; + jsClassMethodType = { fg = mkRaw "base0E"; }; + jsRegexpString = { fg = mkRaw "base0C"; }; + jsGlobalObjects = { fg = mkRaw "base0A"; }; + jsGlobalNodeObjects = { fg = mkRaw "base0A"; }; + jsExceptions = { fg = mkRaw "base0A"; }; + jsBuiltins = { fg = mkRaw "base0A"; }; - # Mail highlighting - mailQuoted1 = { fg = mkRaw "base0A"; }; - mailQuoted2 = { fg = mkRaw "base0B"; }; - mailQuoted3 = { fg = mkRaw "base0E"; }; - mailQuoted4 = { fg = mkRaw "base0C"; }; - mailQuoted5 = { fg = mkRaw "base0D"; }; - mailQuoted6 = { fg = mkRaw "base0A"; }; - mailURL = { fg = mkRaw "base0D"; }; - mailEmail = { fg = mkRaw "base0D"; }; + # Mail highlighting + mailQuoted1 = { fg = mkRaw "base0A"; }; + mailQuoted2 = { fg = mkRaw "base0B"; }; + mailQuoted3 = { fg = mkRaw "base0E"; }; + mailQuoted4 = { fg = mkRaw "base0C"; }; + mailQuoted5 = { fg = mkRaw "base0D"; }; + mailQuoted6 = { fg = mkRaw "base0A"; }; + mailURL = { fg = mkRaw "base0D"; }; + mailEmail = { fg = mkRaw "base0D"; }; - # Markdown highlighting - markdownh1 = { fg = mkRaw "base0D"; gui = "bold"; }; - markdownh2 = { fg = mkRaw "base0D"; gui = "bold"; }; - markdownh3 = { fg = mkRaw "base0D"; gui = "bold"; }; - markdownh4 = { fg = mkRaw "base0D"; gui = "bold"; }; - markdownh5 = { fg = mkRaw "base0D"; gui = "bold"; }; - markdownh6 = { fg = mkRaw "base0A"; gui = "bold"; }; - markdownRule = { fg = mkRaw "markdownh2.bg"; gui = "bold"; }; - markdownItalic = { fg = mkRaw "base05"; gui = "italic"; }; - markdownBold = { fg = mkRaw "base05"; gui = "bold"; }; - markdownBoldItalic = { fg = mkRaw "base05"; gui = "bold;italic"; }; - markdownCodeDelimiter = { fg = mkRaw "base0B"; gui = "bold"; }; - markdownCode = { fg = mkRaw "base07"; bg = mkRaw "base00"; }; - markdownCodeBlock = { fg = mkRaw "base0B"; }; - markdownFootnoteDefinition = { fg = mkRaw "base05"; gui = "italic"; }; - markdownListMarker = { fg = mkRaw "base05"; gui = "bold"; }; - markdownLineBreak = { fg = mkRaw "base08"; gui = "underline"; }; - markdownError = { fg = mkRaw "base05"; bg = mkRaw "base00"; }; - markdownHeadingDelimiter = { fg = mkRaw "base0D"; }; - markdownUrl = { fg = mkRaw "base09"; }; - markdownFootnote = { fg = mkRaw "base0E"; gui = "italic"; }; - markdownBlockquote = { fg = mkRaw "base0C"; gui = "bold"; }; - markdownLinkText = { fg = mkRaw "base08"; gui = "italic"; }; + # Markdown highlighting + markdownh1 = { + fg = mkRaw "base0D"; + gui = "bold"; + }; + markdownh2 = { + fg = mkRaw "base0D"; + gui = "bold"; + }; + markdownh3 = { + fg = mkRaw "base0D"; + gui = "bold"; + }; + markdownh4 = { + fg = mkRaw "base0D"; + gui = "bold"; + }; + markdownh5 = { + fg = mkRaw "base0D"; + gui = "bold"; + }; + markdownh6 = { + fg = mkRaw "base0A"; + gui = "bold"; + }; + markdownRule = { + fg = mkRaw "markdownh2.bg"; + gui = "bold"; + }; + markdownItalic = { + fg = mkRaw "base05"; + gui = "italic"; + }; + markdownBold = { + fg = mkRaw "base05"; + gui = "bold"; + }; + markdownBoldItalic = { + fg = mkRaw "base05"; + gui = "bold;italic"; + }; + markdownCodeDelimiter = { + fg = mkRaw "base0B"; + gui = "bold"; + }; + markdownCode = { + fg = mkRaw "base07"; + bg = mkRaw "base00"; + }; + markdownCodeBlock = { fg = mkRaw "base0B"; }; + markdownFootnoteDefinition = { + fg = mkRaw "base05"; + gui = "italic"; + }; + markdownListMarker = { + fg = mkRaw "base05"; + gui = "bold"; + }; + markdownLineBreak = { + fg = mkRaw "base08"; + gui = "underline"; + }; + markdownError = { + fg = mkRaw "base05"; + bg = mkRaw "base00"; + }; + markdownHeadingDelimiter = { fg = mkRaw "base0D"; }; + markdownUrl = { fg = mkRaw "base09"; }; + markdownFootnote = { + fg = mkRaw "base0E"; + gui = "italic"; + }; + markdownBlockquote = { + fg = mkRaw "base0C"; + gui = "bold"; + }; + markdownLinkText = { + fg = mkRaw "base08"; + gui = "italic"; + }; - # PHP highlighting - phpMemberSelector = { fg = mkRaw "base05"; }; - phpComparison = { fg = mkRaw "base05"; }; - phpParent = { fg = mkRaw "base05"; }; - phpMethodsVar = { fg = mkRaw "base0C"; }; + # PHP highlighting + phpMemberSelector = { fg = mkRaw "base05"; }; + phpComparison = { fg = mkRaw "base05"; }; + phpParent = { fg = mkRaw "base05"; }; + phpMethodsVar = { fg = mkRaw "base0C"; }; - # Python highlighting - pythonOperator = { fg = mkRaw "base0E"; }; - pythonRepeat = { fg = mkRaw "base0E"; }; - pythonInclude = { fg = mkRaw "base0E"; }; - pythonStatement = { fg = mkRaw "base0E"; }; + # Python highlighting + pythonOperator = { fg = mkRaw "base0E"; }; + pythonRepeat = { fg = mkRaw "base0E"; }; + pythonInclude = { fg = mkRaw "base0E"; }; + pythonStatement = { fg = mkRaw "base0E"; }; - # Ruby highlighting - rubyAttribute = { fg = mkRaw "base0D"; }; - rubyConstant = { fg = mkRaw "base0A"; }; - rubyInterpolationDelimiter = { fg = mkRaw "base0F"; }; - rubyRegexp = { fg = mkRaw "base0C"; }; - rubySymbol = { fg = mkRaw "base0B"; }; - rubyStringDelimiter = { fg = mkRaw "base0B"; }; + # Ruby highlighting + rubyAttribute = { fg = mkRaw "base0D"; }; + rubyConstant = { fg = mkRaw "base0A"; }; + rubyInterpolationDelimiter = { fg = mkRaw "base0F"; }; + rubyRegexp = { fg = mkRaw "base0C"; }; + rubySymbol = { fg = mkRaw "base0B"; }; + rubyStringDelimiter = { fg = mkRaw "base0B"; }; - # SASS highlighting - sassidChar = { fg = mkRaw "base08"; }; - sassClassChar = { fg = mkRaw "base09"; }; - sassInclude = { fg = mkRaw "base0E"; }; - sassMixing = { fg = mkRaw "base0E"; }; - sassMixinName = { fg = mkRaw "base0D"; }; + # SASS highlighting + sassidChar = { fg = mkRaw "base08"; }; + sassClassChar = { fg = mkRaw "base09"; }; + sassInclude = { fg = mkRaw "base0E"; }; + sassMixing = { fg = mkRaw "base0E"; }; + sassMixinName = { fg = mkRaw "base0D"; }; - # Spelling highlighting - SpellBad = { gui = "undercurl"; }; - SpellCap = { gui = "undercurl"; }; - SpellRare = { gui = "undercurl"; }; + # Spelling highlighting + SpellBad = { gui = "undercurl"; }; + SpellCap = { gui = "undercurl"; }; + SpellRare = { gui = "undercurl"; }; - # Java highlighting - javaOperator = { fg = mkRaw "base0D"; }; + # Java highlighting + javaOperator = { fg = mkRaw "base0D"; }; - # XML highlighting - xmlTagName = { fg = mkRaw "base0D"; }; - xmlCdatastart = { fg = mkRaw "base0A"; }; - xmlEndTag = { fg = mkRaw "xmlTagName.bg"; }; - xmlCdataCdata = { fg = mkRaw "xmlCdatastart.bg"; }; + # XML highlighting + xmlTagName = { fg = mkRaw "base0D"; }; + xmlCdatastart = { fg = mkRaw "base0A"; }; + xmlEndTag = { fg = mkRaw "xmlTagName.bg"; }; + xmlCdataCdata = { fg = mkRaw "xmlCdatastart.bg"; }; - # MatchParen - MatchParen = { fg = mkRaw "base07"; bg = mkRaw "base08"; }; + # MatchParen + MatchParen = { + fg = mkRaw "base07"; + bg = mkRaw "base08"; + }; - # CodeQL - CodeqlAstFocus = { fg = mkRaw "base00"; bg = mkRaw "base03"; }; + # CodeQL + CodeqlAstFocus = { + fg = mkRaw "base00"; + bg = mkRaw "base03"; + }; - # Diff highlighting - GitSignsAdd = { fg = mkRaw "base0B"; }; - GitSignsDelete = { fg = mkRaw "base08"; }; - GitSignsChange = { fg = mkRaw "base03"; }; - } + # Diff highlighting + GitSignsAdd = { fg = mkRaw "base0B"; }; + GitSignsDelete = { fg = mkRaw "base08"; }; + GitSignsChange = { fg = mkRaw "base03"; }; + } - (lib.mkIf config.plugins.telescope.enable { - TelescopeNormal = { fg = mkRaw "base05"; bg = mkRaw "base01"; }; - TelescopeBorder = { fg = mkRaw "base00"; bg = mkRaw "base01"; }; - TelescopePromptPrefix = { fg = mkRaw "base0A"; bg = mkRaw "base01"; }; - TelescopeMatching = { fg = mkRaw "base0D"; bg = mkRaw "base01"; }; - TelescopeSelection = { fg = mkRaw "base0A"; bg = mkRaw "base01"; }; - TelescopeSelectionCaret = { fg = mkRaw "base0A"; bg = mkRaw "base01"; }; - }) - - # See `rb-delimiters-colors` help section for more details. - (lib.mkIf config.plugins.rainbow-delimiters.enable { - RainbowDelimiterRed = { fg = mkRaw "base09"; }; - RainbowDelimiterYellow = { fg = mkRaw "base0A"; }; - RainbowDelimiterBlue = { fg = mkRaw "base0B"; }; - RainbowDelimiterOrange = { fg = mkRaw "base0C"; }; - RainbowDelimiterGreen = { fg = mkRaw "base0D"; }; - RainbowDelimiterViolet = { fg = mkRaw "base0E"; }; - RainbowDelimiterCyan = { fg = mkRaw "base0F"; }; - }) - - # See `lsp-highlight` help section for more details. - (lib.mkIf config.plugins.lsp.enable { - LspDiagnosticsDefaultError = { fg = mkRaw "base08"; }; - LspDiagnosticsDefaultWarning = { fg = mkRaw "base09"; }; - LspDiagnosticsDefaultHint = { fg = mkRaw "base0A"; }; - LspDiagnosticsDefaultInformation = { fg = mkRaw "base0B"; }; - }) - - # See `treesitter-highlight-groups` help section for more details. - (lib.mkIf config.plugins.treesitter.enable { - ${sym "@variable"} = helpers.listToUnkeyedAttrs [ (mkRaw "Normal") ]; - ${sym "@tag.delimiter"} = { fg = mkRaw "base0A"; }; - ${sym "@text.emphasis"} = helpers.listToUnkeyedAttrs [ (mkRaw "Italic") ]; - ${sym "@text.underline"} = helpers.listToUnkeyedAttrs [ (mkRaw "Underlined") ]; - ${sym "@text.strike"} = { gui = "strikethrough"; }; - ${sym "@text.uri"} = { fg = mkRaw "base0C"; }; - }) - - (lib.mkIf config.plugins.indent-blankline.enable { - IblScope = { fg = mkRaw "base0C"; gui = "bold"; } ; - }) - ]; + (lib.mkIf config.plugins.telescope.enable { + TelescopeNormal = { + fg = mkRaw "base05"; + bg = mkRaw "base01"; + }; + TelescopeBorder = { + fg = mkRaw "base00"; + bg = mkRaw "base01"; + }; + TelescopePromptPrefix = { + fg = mkRaw "base0A"; + bg = mkRaw "base01"; + }; + TelescopeMatching = { + fg = mkRaw "base0D"; + bg = mkRaw "base01"; + }; + TelescopeSelection = { + fg = mkRaw "base0A"; + bg = mkRaw "base01"; + }; + TelescopeSelectionCaret = { + fg = mkRaw "base0A"; + bg = mkRaw "base01"; + }; }) - config.bahaghari.tinted-theming.schemes; + + # See `rb-delimiters-colors` help section for more details. + (lib.mkIf config.plugins.rainbow-delimiters.enable { + RainbowDelimiterRed = { fg = mkRaw "base09"; }; + RainbowDelimiterYellow = { fg = mkRaw "base0A"; }; + RainbowDelimiterBlue = { fg = mkRaw "base0B"; }; + RainbowDelimiterOrange = { fg = mkRaw "base0C"; }; + RainbowDelimiterGreen = { fg = mkRaw "base0D"; }; + RainbowDelimiterViolet = { fg = mkRaw "base0E"; }; + RainbowDelimiterCyan = { fg = mkRaw "base0F"; }; + }) + + # See `lsp-highlight` help section for more details. + (lib.mkIf config.plugins.lsp.enable { + LspDiagnosticsDefaultError = { fg = mkRaw "base08"; }; + LspDiagnosticsDefaultWarning = { fg = mkRaw "base09"; }; + LspDiagnosticsDefaultHint = { fg = mkRaw "base0A"; }; + LspDiagnosticsDefaultInformation = { fg = mkRaw "base0B"; }; + }) + + # See `treesitter-highlight-groups` help section for more details. + (lib.mkIf config.plugins.treesitter.enable { + ${sym "@variable"} = helpers.listToUnkeyedAttrs [ (mkRaw "Normal") ]; + ${sym "@tag.delimiter"} = { fg = mkRaw "base0A"; }; + ${sym "@text.emphasis"} = + helpers.listToUnkeyedAttrs [ (mkRaw "Italic") ]; + ${sym "@text.underline"} = + helpers.listToUnkeyedAttrs [ (mkRaw "Underlined") ]; + ${sym "@text.strike"} = { gui = "strikethrough"; }; + ${sym "@text.uri"} = { fg = mkRaw "base0C"; }; + }) + + (lib.mkIf config.plugins.indent-blankline.enable { + IblScope = { + fg = mkRaw "base0C"; + gui = "bold"; + }; + }) + ]; + }) config.bahaghari.tinted-theming.schemes; }; } diff --git a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/dap.nix b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/dap.nix index 3538342a..da339dcf 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/dap.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/dap.nix @@ -11,9 +11,7 @@ args = [ "-i" "dap" ]; }; - lldb = { - command = "lldb-dap"; - }; + lldb = { command = "lldb-dap"; }; dart = { command = "dart"; diff --git a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/default.nix b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/default.nix index c193cc85..6afbde9f 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/default.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/default.nix @@ -14,8 +14,7 @@ let module.imports = firstSetupArgs.baseNixvimModules ++ [ module ]; extraSpecialArgs.hmConfig = config; }; -in -{ +in { options.users.foo-dogsquared.programs.nixvim.enable = lib.mkEnableOption "NixVim setup"; @@ -29,22 +28,21 @@ in wrapper-manager.packages.neovim-flavors = { wrappers.nvim-fiesta.arg0 = let nvimPkg = createNixvimFlavor { - imports = - [ - ./colorschemes.nix - ./fuzzy-finding.nix - ./misc.nix - ./note-taking.nix - ] - ++ lib.optionals userCfg.setups.development.enable [ - ./dev.nix - ./lsp.nix - ./dap.nix - ]; + imports = [ + ./colorschemes.nix + ./fuzzy-finding.nix + ./misc.nix + ./note-taking.nix + ] ++ lib.optionals userCfg.setups.development.enable [ + ./dev.nix + ./lsp.nix + ./dap.nix + ]; config = { # Inherit all of the schemes. - bahaghari.tinted-theming.schemes = hmCfg.bahaghari.tinted-theming.schemes; + bahaghari.tinted-theming.schemes = + hmCfg.bahaghari.tinted-theming.schemes; }; }; in lib.getExe' nvimPkg "nvim"; diff --git a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/dev.nix b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/dev.nix index 102b2609..f26c95c7 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/dev.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/dev.nix @@ -22,7 +22,8 @@ # Give language "support" through tree-sitter. plugins.treesitter.grammarPackages = - with config.plugins.treesitter.package.builtGrammars; [ + with config.plugins.treesitter.package.builtGrammars; + [ agda arduino astro @@ -54,6 +55,7 @@ kotlin make nickel + nix perl ruby rust @@ -64,15 +66,7 @@ wgsl wgsl_bevy zig - ] - ++ (with pkgs.tree-sitter-grammars; [ - tree-sitter-elisp - tree-sitter-nu - ]); + ] ++ (with pkgs.tree-sitter-grammars; [ tree-sitter-elisp tree-sitter-nu ]); - extraPlugins = with pkgs.vimPlugins; [ - vim-nickel - vim-nix - zig-vim - ]; + extraPlugins = with pkgs.vimPlugins; [ vim-nickel vim-nix zig-vim ]; } diff --git a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/fuzzy-finding.nix b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/fuzzy-finding.nix index a1735644..c780c06d 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/fuzzy-finding.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/fuzzy-finding.nix @@ -3,8 +3,7 @@ let inherit (hmConfig.xdg) userDirs; telescopeExtensions = config.plugins.telescope.extensions; -in -{ +in { plugins.telescope.extensions.frecency = { enable = true; settings = { @@ -18,15 +17,14 @@ in }; }; - plugins.telescope.extensions.live-grep-args = { - enable = true; - }; + plugins.telescope.extensions.live-grep-args = { enable = true; }; - keymaps = - lib.optionals telescopeExtensions.live-grep-args.enable (lib.singleton { + keymaps = lib.optionals telescopeExtensions.live-grep-args.enable + (lib.singleton { mode = "n"; key = "fG"; options.desc = "Live grep (with args) for the whole project"; - action = helpers.mkRaw "require('telescope').extensions.live_grep_args.live_grep_args"; + action = helpers.mkRaw + "require('telescope').extensions.live_grep_args.live_grep_args"; }); } diff --git a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/lsp.nix b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/lsp.nix index 9f2dea1f..13f57167 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/lsp.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/lsp.nix @@ -17,7 +17,7 @@ # For HTML. html = { - enable = true; + enable = true; autostart = false; }; diff --git a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/misc.nix b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/misc.nix index 382f0486..737c0b2d 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/nixvim/misc.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/nixvim/misc.nix @@ -1,16 +1,12 @@ { config, lib, pkgs, hmConfig, ... }: -let - userConfig = hmConfig.users.foo-dogsquared; -in -{ - extraPlugins = builtins.map - (path: - pkgs.runCommand "vim-plugin-bare" { } '' - mkdir -p "$out" - cp -r ${path}/* "$out" - '') - (with pkgs; [ +let userConfig = hmConfig.users.foo-dogsquared; +in { + extraPlugins = builtins.map (path: + pkgs.runCommand "vim-plugin-bare" { } '' + mkdir -p "$out" + cp -r ${path}/* "$out" + '') (with pkgs; [ "${decker}/share/vim-plugins/decker" "${fzf}/share/vim-plugins/fzf" ]); diff --git a/configs/home-manager/foo-dogsquared/modules/programs/nushell.nix b/configs/home-manager/foo-dogsquared/modules/programs/nushell.nix index 377ee5f0..967f0de9 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/nushell.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/nushell.nix @@ -5,8 +5,7 @@ let cfg = userCfg.programs.nushell; nushellAutoloadScriptDir = "${config.xdg.dataHome}/nushell/vendor/autoload"; -in -{ +in { options.users.foo-dogsquared.programs.nushell.enable = lib.mkEnableOption "Nushell setup"; @@ -20,7 +19,6 @@ in skim polars units - net formats highlight ]; @@ -35,11 +33,10 @@ in } } ''; - environmentVariables.NU_LIB_DIRS = - lib.concatStringsSep ":" [ - "${config.xdg.cacheHome}/nushell/modules" - "${config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR}/nushell" - ]; + environmentVariables.NU_LIB_DIRS = lib.concatStringsSep ":" [ + "${config.xdg.cacheHome}/nushell/modules" + "${config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR}/nushell" + ]; }; } @@ -76,9 +73,11 @@ in } match $spans.0 { - ${lib.optionalString config.programs.zoxide.enable '' - __zoxide_z | __zoxide_zi => $zoxide_completer - ''} + ${ + lib.optionalString config.programs.zoxide.enable '' + __zoxide_z | __zoxide_zi => $zoxide_completer + '' + } _ => $carapace_completer } | do $in $spans } diff --git a/configs/home-manager/foo-dogsquared/modules/programs/shell.nix b/configs/home-manager/foo-dogsquared/modules/programs/shell.nix index f133d244..cc374ee8 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/shell.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/shell.nix @@ -4,10 +4,9 @@ let userCfg = config.users.foo-dogsquared; cfg = userCfg.programs.shell; -in -{ - options.users.foo-dogsquared.programs.shell.enable = - lib.mkEnableOption "configuration of foo-dogsquared's shell of choice and its toolbelt"; +in { + options.users.foo-dogsquared.programs.shell.enable = lib.mkEnableOption + "configuration of foo-dogsquared's shell of choice and its toolbelt"; config = lib.mkIf cfg.enable { suites.dev.shell.enable = lib.mkDefault true; @@ -15,21 +14,12 @@ in programs.bash = { enable = true; historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; - historyIgnore = [ - "cd" - "exit" - "lf" - "ls" - "nvim" - ]; + historyIgnore = [ "cd" "exit" "lf" "ls" "nvim" ]; }; # Additional formatting thingies for your fuzzy finder. - programs.fzf.defaultOptions = [ - "--height=40%" - "--bind=ctrl-z:ignore" - "--reverse" - ]; + programs.fzf.defaultOptions = + [ "--height=40%" "--bind=ctrl-z:ignore" "--reverse" ]; # Compile all of the completions. programs.carapace.enable = true; diff --git a/configs/home-manager/foo-dogsquared/modules/programs/terminal-emulator.nix b/configs/home-manager/foo-dogsquared/modules/programs/terminal-emulator.nix index a3496844..d530c3b1 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/terminal-emulator.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/terminal-emulator.nix @@ -10,8 +10,7 @@ let ''; hasNixosModuleEnable = attrs.nixosConfig.programs.wezterm.enable or false; -in -{ +in { options.users.foo-dogsquared.programs.terminal-emulator.enable = lib.mkEnableOption "foo-dogsquared's terminal emulator setup"; @@ -19,39 +18,33 @@ in { # We're just making a version of Wezterm with the default arguments if # the user has them. - home.packages = - let - inherit (pkgs) wezterm hiPrio; - weztermUserDefaultDesktop = pkgs.makeDesktopItem { - name = "org.wezfurlong.wezterm"; - desktopName = "WezTerm (user)"; - comment = "Wez's Terminal Emulator"; - keywords = [ "shell" "prompt" "command" "commandline" "cmd" ]; - icon = "org.wezfurlong.wezterm"; - startupWMClass = "org.wezfurlong.wezterm"; - tryExec = "wezterm"; - exec = "wezterm"; - type = "Application"; - categories = [ "System" "TerminalEmulator" "Utility" ]; - }; - weztermTypicalDesktop = pkgs.makeDesktopItem { - name = "wezterm-start"; - desktopName = "WezTerm"; - comment = "Wez's Terminal Emulator"; - keywords = [ "shell" "prompt" "command" "commandline" "cmd" ]; - icon = "org.wezfurlong.wezterm"; - startupWMClass = "org.wezfurlong.wezterm"; - tryExec = "wezterm"; - exec = "wezterm start --cwd ."; - type = "Application"; - categories = [ "System" "TerminalEmulator" "Utility" ]; - }; - in - [ - wezterm - (hiPrio weztermUserDefaultDesktop) - weztermTypicalDesktop - ]; + home.packages = let + inherit (pkgs) wezterm hiPrio; + weztermUserDefaultDesktop = pkgs.makeDesktopItem { + name = "org.wezfurlong.wezterm"; + desktopName = "WezTerm (user)"; + comment = "Wez's Terminal Emulator"; + keywords = [ "shell" "prompt" "command" "commandline" "cmd" ]; + icon = "org.wezfurlong.wezterm"; + startupWMClass = "org.wezfurlong.wezterm"; + tryExec = "wezterm"; + exec = "wezterm"; + type = "Application"; + categories = [ "System" "TerminalEmulator" "Utility" ]; + }; + weztermTypicalDesktop = pkgs.makeDesktopItem { + name = "wezterm-start"; + desktopName = "WezTerm"; + comment = "Wez's Terminal Emulator"; + keywords = [ "shell" "prompt" "command" "commandline" "cmd" ]; + icon = "org.wezfurlong.wezterm"; + startupWMClass = "org.wezfurlong.wezterm"; + tryExec = "wezterm"; + exec = "wezterm start --cwd ."; + type = "Application"; + categories = [ "System" "TerminalEmulator" "Utility" ]; + }; + in [ wezterm (hiPrio weztermUserDefaultDesktop) weztermTypicalDesktop ]; } (lib.mkIf (!hasNixosModuleEnable) { diff --git a/configs/home-manager/foo-dogsquared/modules/programs/terminal-multiplexer.nix b/configs/home-manager/foo-dogsquared/modules/programs/terminal-multiplexer.nix index 7c0fe1b8..1ac098ea 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/terminal-multiplexer.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/terminal-multiplexer.nix @@ -3,8 +3,7 @@ let userCfg = config.users.foo-dogsquared; cfg = userCfg.programs.terminal-multiplexer; -in -{ +in { options.users.foo-dogsquared.programs.terminal-multiplexer.enable = lib.mkEnableOption "foo-dogsquared's terminal multiplexer setup"; diff --git a/configs/home-manager/foo-dogsquared/modules/programs/vs-code.nix b/configs/home-manager/foo-dogsquared/modules/programs/vs-code.nix index f53dfa39..2141714e 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/vs-code.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/vs-code.nix @@ -3,42 +3,38 @@ let userCfg = config.users.foo-dogsquared; cfg = userCfg.programs.vs-code; -in -{ +in { options.users.foo-dogsquared.programs.vs-code.enable = lib.mkEnableOption "foo-dogsquared's Visual Studio Code setup"; config = lib.mkIf cfg.enable { suites.editors.vscode.enable = true; programs.vscode = { - extensions = with pkgs.vscode-extensions; [ - # Additional language support. - bbenoist.nix - graphql.vscode-graphql - ms-python.python - ms-azuretools.vscode-docker - ms-vscode.cmake-tools - ms-vscode.cpptools - ms-vscode.powershell + extensions = with pkgs.vscode-extensions; + [ + # Additional language support. + bbenoist.nix + graphql.vscode-graphql + ms-python.python + ms-azuretools.vscode-docker + ms-vscode.cmake-tools + ms-vscode.cpptools + ms-vscode.powershell - # Extra editor niceties. - eamodio.gitlens - mkhl.direnv - usernamehw.errorlens - vadimcn.vscode-lldb + # Extra editor niceties. + eamodio.gitlens + mkhl.direnv + usernamehw.errorlens + vadimcn.vscode-lldb - # The other niceties. - editorconfig.editorconfig - alefragnani.project-manager - fill-labs.dependi - ] - ++ lib.optionals userCfg.programs.browsers.firefox.enable [ - firefox-devtools.vscode-firefox-debug - ]; + # The other niceties. + editorconfig.editorconfig + alefragnani.project-manager + fill-labs.dependi + ] ++ lib.optionals userCfg.programs.browsers.firefox.enable + [ firefox-devtools.vscode-firefox-debug ]; - userSettings = { - "extensions.ignoreRecommendations" = true; - }; + userSettings = { "extensions.ignoreRecommendations" = true; }; }; # We're using Visual Studio Code as a git difftool and mergetool which is diff --git a/configs/home-manager/foo-dogsquared/modules/services/archivebox/default.nix b/configs/home-manager/foo-dogsquared/modules/services/archivebox/default.nix index e3d540ae..19e9e21e 100644 --- a/configs/home-manager/foo-dogsquared/modules/services/archivebox/default.nix +++ b/configs/home-manager/foo-dogsquared/modules/services/archivebox/default.nix @@ -47,8 +47,7 @@ let }; }; }; -in -{ +in { options.users.foo-dogsquared.services.archivebox = { enable = lib.mkEnableOption "ArchiveBox web UI server (through Podman)"; @@ -97,24 +96,28 @@ in }; services.podman.containers = lib.mkMerge [ - (lib.mapAttrs' (name: value: lib.nameValuePair (jobUnitName name) { - image = "docker.io/archivebox/archivebox:latest"; - description = "ArchiveBox job '${name}'"; - volumes = [ "${archiveboxDir}:/data" ]; - autoUpdate = "registry"; - exec = ''echo "${lib.concatStringsSep "\n" value.links}" | archivebox add ${lib.concatStringsSep " " value.extraArgs}''; - environmentFile = config.services.podman.containers.archivebox-webui.environmentFile; - environment = config.services.podman.containers.archivebox-webui.environment; - }) cfg.jobs) + (lib.mapAttrs' (name: value: + lib.nameValuePair (jobUnitName name) { + image = "docker.io/archivebox/archivebox:latest"; + description = "ArchiveBox job '${name}'"; + volumes = [ "${archiveboxDir}:/data" ]; + autoUpdate = "registry"; + exec = '' + echo "${lib.concatStringsSep "\n" value.links}" | archivebox add ${ + lib.concatStringsSep " " value.extraArgs + }''; + environmentFile = + config.services.podman.containers.archivebox-webui.environmentFile; + environment = + config.services.podman.containers.archivebox-webui.environment; + }) cfg.jobs) { archivebox-webui = { image = "docker.io/archivebox/archivebox:latest"; description = "ArchiveBox web server"; ports = [ "${port}:${port}" ]; - volumes = [ - "${archiveboxDir}:/data" - ]; + volumes = [ "${archiveboxDir}:/data" ]; autoUpdate = "registry"; exec = "archivebox server ${url}"; environmentFile = [ "${config.sops.secrets."archivebox/env".path}" ]; @@ -135,8 +138,7 @@ in archivebox-sonic-search = { image = "docker.io/archivebox/sonic:latest"; description = "Sonic search instance for ArchiveBox"; - ports = let - port = builtins.toString config.state.ports.sonic.value; + ports = let port = builtins.toString config.state.ports.sonic.value; in [ "${port}:${port}" ]; environmentFile = [ "${config.sops.secrets."sonic/env".path}" ]; volumes = [ @@ -148,9 +150,10 @@ in } ]; - users.foo-dogsquared.programs.custom-homepage.sections.services.links = lib.singleton { - url = "${url}/public"; - text = "Link archive"; - }; + users.foo-dogsquared.programs.custom-homepage.sections.services.links = + lib.singleton { + url = "${url}/public"; + text = "Link archive"; + }; }; } diff --git a/configs/home-manager/foo-dogsquared/modules/services/backup/default.nix b/configs/home-manager/foo-dogsquared/modules/services/backup/default.nix index 839e1dcd..675f5772 100644 --- a/configs/home-manager/foo-dogsquared/modules/services/backup/default.nix +++ b/configs/home-manager/foo-dogsquared/modules/services/backup/default.nix @@ -5,73 +5,66 @@ let cfg = userCfg.services.backup; pathPrefix = "borg-backup"; - getPath = path: - config.sops.secrets."${pathPrefix}/${path}".path; + getPath = path: config.sops.secrets."${pathPrefix}/${path}".path; isFilesystemSet = setupName: attrs.nixosConfig.suites.filesystem.setups.${setupName}.enable or false; hetznerBoxesUser = "u332477"; hetznerBoxesServer = "${hetznerBoxesUser}.your-storagebox.de"; - borgmaticCommonConfig = module: lib.mkMerge [ - module + borgmaticCommonConfig = module: + lib.mkMerge [ + module - { - archive_name_format = lib.mkDefault "{fqdn}-home-manager-personal-{now}"; - patterns = lib.mkBefore [ - "R ${config.home.homeDirectory}" - "! ${config.xdg.dataHome}" - "! ${config.xdg.cacheHome}" - "- ${config.xdg.configHome}" - "- ${config.xdg.userDirs.download}" - "+ ${config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR}" - "+ ${config.xdg.userDirs.documents}" - "+ ${config.xdg.userDirs.music}" - "+ ${config.xdg.userDirs.pictures}" - "+ ${config.xdg.userDirs.templates}" - "+ ${config.xdg.userDirs.videos}" - "+ ${config.home.homeDirectory}/.thunderbird" - "+ ${config.xdg.dataHome}/gopass" - "+ ${config.xdg.configHome}/age" - "+ ${config.xdg.configHome}/sops" - ]; - exclude_if_present = [ - ".nobackup" - ".exclude.bak" - ]; - exclude_patterns = [ - "node_modules/" - "*.pyc" - "result*/" - "*/.vim*.tmp" - "target/" - ]; + { + archive_name_format = + lib.mkDefault "{fqdn}-home-manager-personal-{now}"; + patterns = lib.mkBefore [ + "R ${config.home.homeDirectory}" + "! ${config.xdg.dataHome}" + "! ${config.xdg.cacheHome}" + "- ${config.xdg.configHome}" + "- ${config.xdg.userDirs.download}" + "+ ${config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR}" + "+ ${config.xdg.userDirs.documents}" + "+ ${config.xdg.userDirs.music}" + "+ ${config.xdg.userDirs.pictures}" + "+ ${config.xdg.userDirs.templates}" + "+ ${config.xdg.userDirs.videos}" + "+ ${config.home.homeDirectory}/.thunderbird" + "+ ${config.xdg.dataHome}/gopass" + "+ ${config.xdg.configHome}/age" + "+ ${config.xdg.configHome}/sops" + ]; + exclude_if_present = [ ".nobackup" ".exclude.bak" ]; + exclude_patterns = + [ "node_modules/" "*.pyc" "result*/" "*/.vim*.tmp" "target/" ]; - store_config_files = true; + store_config_files = true; - # Most of these retention settings are meant to have overlaps in the - # periodic backups. - keep_hourly = 48; - keep_daily = 14; - keep_weekly = 8; - keep_monthly = 12; - keep_yearly = 4; + # Most of these retention settings are meant to have overlaps in the + # periodic backups. + keep_hourly = 48; + keep_daily = 14; + keep_weekly = 8; + keep_monthly = 12; + keep_yearly = 4; - check_last = 4; - } - ]; + check_last = 4; + } + ]; - checkRemovableMountScript = pkgs.writeShellScript "check-for-removable-storage" '' - { findmnt "$(dirname "$1")" > /dev/null && [ -d "$1" ]; } || exit 75 - ''; -in -{ + checkRemovableMountScript = + pkgs.writeShellScript "check-for-removable-storage" '' + { findmnt "$(dirname "$1")" > /dev/null && [ -d "$1" ]; } || exit 75 + ''; +in { options.users.foo-dogsquared.services.backup.enable = lib.mkEnableOption "preferred backup service"; config = lib.mkIf cfg.enable { - sops.secrets = foodogsquaredLib.sops-nix.getSecrets ./secrets.yaml ( - foodogsquaredLib.sops-nix.attachSopsPathPrefix pathPrefix { + sops.secrets = foodogsquaredLib.sops-nix.getSecrets ./secrets.yaml + (foodogsquaredLib.sops-nix.attachSopsPathPrefix pathPrefix { "repos/remote-hetzner-boxes-personal/password" = { }; "repos/local-external-hdd-personal/password" = { }; "repos/local-archive-personal/password" = { }; @@ -84,15 +77,18 @@ in initService.enable = true; initService.startAt = "06:30"; settings = borgmaticCommonConfig { - encryption_passcommand = "cat ${getPath "repos/remote-hetzner-boxes-personal/password"}"; + encryption_passcommand = + "cat ${getPath "repos/remote-hetzner-boxes-personal/password"}"; repositories = lib.singleton { - path = "ssh://${hetznerBoxesUser}@${hetznerBoxesServer}:23/./borg/users/${config.home.username}"; + path = + "ssh://${hetznerBoxesUser}@${hetznerBoxesServer}:23/./borg/users/${config.home.username}"; label = "remote-hetzner-boxes"; }; extra_borg_options = { init = builtins.toString [ "--make-parent-dirs" - "--encryption" "repokey-blake2" + "--encryption" + "repokey-blake2" ]; }; }; @@ -104,14 +100,17 @@ in initService.enable = true; initService.startAt = "04:30"; settings = let - removablePath = "${attrs.nixosConfig.state.paths.external-hdd}/Backups"; + removablePath = + "${attrs.nixosConfig.state.paths.external-hdd}/Backups"; in borgmaticCommonConfig { - encryption_passcommand = "cat ${getPath "repos/local-external-hdd-personal/password"}"; + encryption_passcommand = + "cat ${getPath "repos/local-external-hdd-personal/password"}"; repositories = lib.singleton { path = removablePath; label = "local-external-hdd"; }; - before_backup = lib.singleton "${checkRemovableMountScript} ${removablePath}"; + before_backup = + lib.singleton "${checkRemovableMountScript} ${removablePath}"; }; }; }) @@ -121,9 +120,11 @@ in initService.enable = true; initService.startAt = "04:30"; settings = borgmaticCommonConfig { - encryption_passcommand = "cat ${getPath "repos/local-archive-personal/password"}"; + encryption_passcommand = + "cat ${getPath "repos/local-archive-personal/password"}"; repositories = lib.singleton { - path = "\${BORG_PERSONAL_FDS_PATH:-${attrs.nixosConfig.state.paths.laptop-ssd}/Backups/foodogsquared}"; + path = + "\${BORG_PERSONAL_FDS_PATH:-${attrs.nixosConfig.state.paths.laptop-ssd}/Backups/foodogsquared}"; label = "local-archive"; }; }; @@ -136,13 +137,18 @@ in enable = true; startAt = "daily"; - settings = let - backup_path = "${config.xdg.cacheHome}/ludusavi/backups"; + settings = let backup_path = "${config.xdg.cacheHome}/ludusavi/backups"; in { manifest.enable = true; roots = [ - { path = "${config.home.homeDirectory}/.steam"; store = "steam"; } - { path = "${config.xdg.dataHome}/lutris"; store = "lutris"; } + { + path = "${config.home.homeDirectory}/.steam"; + store = "steam"; + } + { + path = "${config.xdg.dataHome}/lutris"; + store = "lutris"; + } ]; backup.path = backup_path; restore.path = backup_path; diff --git a/configs/home-manager/foo-dogsquared/modules/setups/business.nix b/configs/home-manager/foo-dogsquared/modules/setups/business.nix index 6a9b5151..584ccc2c 100644 --- a/configs/home-manager/foo-dogsquared/modules/setups/business.nix +++ b/configs/home-manager/foo-dogsquared/modules/setups/business.nix @@ -3,16 +3,11 @@ let userCfg = config.users.foo-dogsquared; cfg = userCfg.setups.business; -in -{ +in { options.users.foo-dogsquared.setups.business.enable = lib.mkEnableOption "business setup"; config = lib.mkIf cfg.enable { - home.packages = with pkgs; [ - collabora-online - libreoffice - zoom-us - ]; + home.packages = with pkgs; [ collabora-online libreoffice zoom-us ]; }; } diff --git a/configs/home-manager/foo-dogsquared/modules/setups/desktop.nix b/configs/home-manager/foo-dogsquared/modules/setups/desktop.nix index 131c7659..362d4288 100644 --- a/configs/home-manager/foo-dogsquared/modules/setups/desktop.nix +++ b/configs/home-manager/foo-dogsquared/modules/setups/desktop.nix @@ -4,18 +4,14 @@ let userCfg = config.users.foo-dogsquared; cfg = userCfg.setups.desktop; -in -{ +in { options.users.foo-dogsquared.setups.desktop.enable = lib.mkEnableOption "a set of usual desktop productivity services"; config = lib.mkIf cfg.enable { state.ports.activitywatch.value = 5600; - home.packages = with pkgs; [ - bitwarden-cli - bitwarden-desktop - ]; + home.packages = with pkgs; [ bitwarden-cli bitwarden-desktop ]; # Install all of the desktop stuff. suites.desktop = { @@ -66,19 +62,14 @@ in startAt = "daily"; settings = { topdirs = "~/Downloads ~/Documents ~/library"; - "skippedNames+" = - let - inherit (config.state.paths) ignoreDirectories; - in - lib.concatStringsSep " " ignoreDirectories; + "skippedNames+" = let inherit (config.state.paths) ignoreDirectories; + in lib.concatStringsSep " " ignoreDirectories; "~/library/projects" = { "skippedNames+" = ".editorconfig .gitignore result flake.lock go.sum"; }; - "~/library/projects/software" = { - "skippedNames+" = "target result"; - }; + "~/library/projects/software" = { "skippedNames+" = "target result"; }; }; }; @@ -92,9 +83,12 @@ in startAt = "daily"; }; - users.foo-dogsquared.programs.custom-homepage.sections.services.links = lib.singleton { - url = "http://localhost:${builtins.toString config.state.ports.activitywatch.value}"; - text = "Telemetry server"; - }; + users.foo-dogsquared.programs.custom-homepage.sections.services.links = + lib.singleton { + url = "http://localhost:${ + builtins.toString config.state.ports.activitywatch.value + }"; + text = "Telemetry server"; + }; }; } diff --git a/configs/home-manager/foo-dogsquared/modules/setups/development.nix b/configs/home-manager/foo-dogsquared/modules/setups/development.nix index 22317e94..ec7e7d4a 100644 --- a/configs/home-manager/foo-dogsquared/modules/setups/development.nix +++ b/configs/home-manager/foo-dogsquared/modules/setups/development.nix @@ -5,8 +5,7 @@ let cfg = userCfg.setups.development; in { options.users.foo-dogsquared.setups.development = { - enable = - lib.mkEnableOption "foo-dogsquared's software development setup"; + enable = lib.mkEnableOption "foo-dogsquared's software development setup"; creative-coding.enable = lib.mkEnableOption "foo-dogsquared's creative coding setup"; @@ -54,10 +53,12 @@ in { users.foo-dogsquared.programs.custom-homepage.sections.services.links = let - hasCockpitEnabled = attrs.nixosConfig.services.cockpit.enable or false; - in - lib.optionals hasCockpitEnabled (lib.singleton { - url = "http://localhost:${builtins.toString attrs.nixosConfig.services.cockpit.port}"; + hasCockpitEnabled = + attrs.nixosConfig.services.cockpit.enable or false; + in lib.optionals hasCockpitEnabled (lib.singleton { + url = "http://localhost:${ + builtins.toString attrs.nixosConfig.services.cockpit.port + }"; text = "Cockpit WebUI"; }); @@ -69,7 +70,7 @@ in { home.packages = with pkgs; [ cachix # Compile no more by using someone's binary cache! regex-cli # Save some face of confusion for yourself. - dt # Get that functional gawk. + #dt # Get that functional gawk. jq # Get that JSON querying tool. recode # Convert between different encodings. go-migrate # Go potential migraines. @@ -91,10 +92,9 @@ in { ]; } - (lib.mkIf (!userCfg.programs.nixvim.enable) { + (lib.mkIf (!config.programs.nixvim.enable or false) { programs.neovim = { enable = true; - package = pkgs.neovim-nightly; vimAlias = true; vimdiffAlias = true; @@ -105,9 +105,7 @@ in { }) (lib.mkIf userCfg.programs.browsers.firefox.enable { - home.packages = with pkgs; [ - (lowPrio firefox-devedition) - ]; + home.packages = with pkgs; [ (lowPrio firefox-devedition) ]; }) (lib.mkIf userCfg.programs.git.enable { @@ -145,7 +143,7 @@ in { home.packages = with pkgs; [ supercollider-with-plugins processing - (puredata-with-plugins (with pkgs; [ zexy cyclone ])) + #(puredata-with-plugins (with pkgs; [ zexy cyclone ])) ]; }) ]); diff --git a/configs/home-manager/foo-dogsquared/modules/setups/fonts.nix b/configs/home-manager/foo-dogsquared/modules/setups/fonts.nix index dae98ee0..5da6d792 100644 --- a/configs/home-manager/foo-dogsquared/modules/setups/fonts.nix +++ b/configs/home-manager/foo-dogsquared/modules/setups/fonts.nix @@ -3,8 +3,7 @@ let userCfg = config.users.foo-dogsquared; cfg = userCfg.setups.fonts; -in -{ +in { options.users.foo-dogsquared.setups.fonts.enable = lib.mkEnableOption "foo-dogsquared's font setup"; diff --git a/configs/home-manager/foo-dogsquared/modules/setups/music.nix b/configs/home-manager/foo-dogsquared/modules/setups/music.nix index b5ce0ad3..0c2a0433 100644 --- a/configs/home-manager/foo-dogsquared/modules/setups/music.nix +++ b/configs/home-manager/foo-dogsquared/modules/setups/music.nix @@ -10,8 +10,7 @@ let musicDir = config.xdg.userDirs.music; playlistsDir = "${musicDir}/playlists"; -in -{ +in { options.users.foo-dogsquared.setups.music = { enable = lib.mkEnableOption "foo-dogsquared's music setup"; mpd.enable = lib.mkEnableOption "foo-dogsquared's MPD server setup"; @@ -28,9 +27,7 @@ in wrapper-manager.packages.music-setup = { wrappers.yt-dlp-audio = { arg0 = lib.getExe' pkgs.yt-dlp "yt-dlp"; - prependArgs = [ - "--config-location" ../../config/yt-dlp/audio.conf - ]; + prependArgs = [ "--config-location" ../../config/yt-dlp/audio.conf ]; }; }; @@ -107,12 +104,15 @@ in users.foo-dogsquared.programs.custom-homepage.sections = lib.mkMerge [ (lib.mkIf (attrs.nixosConfig.services.gonic.enable or false) (let subsonicLink = { - url = "http://localhost:${builtins.toString attrs.nixosConfig.state.ports.gonic.value}"; + url = "http://localhost:${ + builtins.toString attrs.nixosConfig.state.ports.gonic.value + }"; text = "Jukebox server"; }; in { services.links = lib.singleton subsonicLink; - music.links = lib.mkBefore [ (subsonicLink // { text = "Subsonic music server"; }) ]; + music.links = lib.mkBefore + [ (subsonicLink // { text = "Subsonic music server"; }) ]; })) ]; } @@ -120,26 +120,31 @@ in (lib.mkIf cfg.spotify.enable { home.packages = with pkgs; [ spotify ]; - state.ports.spotifyd.value = attrs.nixosConfig.services.spotifyd.value or 9009; + state.ports.spotifyd.value = + attrs.nixosConfig.services.spotifyd.value or 9009; services.mopidy.extensionPackages = [ pkgs.mopidy-spotify ]; }) - (lib.mkIf (cfg.spotify.enable && !(attrs.nixosConfig.services.spotifyd.enable or false)) { - services.spotifyd = { - enable = true; - settings.global = { - use_mpris = true; - device_name = "foodogsquared's computer"; - bitrate = 320; - device_type = "computer"; - zeroconf_port = config.state.ports.spotifyd.value; + (lib.mkIf (cfg.spotify.enable + && !(attrs.nixosConfig.services.spotifyd.enable or false)) { + services.spotifyd = { + enable = true; + settings.global = { + use_mpris = true; + device_name = "foodogsquared's computer"; + bitrate = 320; + device_type = "computer"; + zeroconf_port = config.state.ports.spotifyd.value; - cache_path = "${config.xdg.cacheHome}/spotifyd"; - max_cache_size = unitsToInt { size = 4; prefix = "G"; }; + cache_path = "${config.xdg.cacheHome}/spotifyd"; + max_cache_size = unitsToInt { + size = 4; + prefix = "G"; + }; + }; }; - }; - }) + }) (lib.mkIf cfg.mpd.enable { state.ports.mopidy.value = 6680; @@ -165,13 +170,10 @@ in file = { enabled = true; - media_dirs = [ - "$XDG_MUSIC_DIR|Music" - "~/library/music|Library" - ] - ++ lib.optional (isFilesystemSet "external-hdd") + media_dirs = [ "$XDG_MUSIC_DIR|Music" "~/library/music|Library" ] + ++ lib.optional (isFilesystemSet "external-hdd") "${attrs.nixosConfig.state.paths.external-hdd}/Music|External storage" - ++ lib.optional (isFilesystemSet "archive") + ++ lib.optional (isFilesystemSet "archive") "${attrs.nixosConfig.state.paths.archive}/Music|Archive"; }; @@ -207,12 +209,15 @@ in # Set this to the custom homepage. users.foo-dogsquared.programs.custom-homepage.sections = let mopidyLink = { - url = "http://localhost:${builtins.toString config.state.ports.mopidy.value}"; + url = "http://localhost:${ + builtins.toString config.state.ports.mopidy.value + }"; text = "Music streaming server"; }; in { services.links = lib.singleton mopidyLink; - music.links = lib.mkBefore [ (mopidyLink // { text = "Mopidy server"; }) ]; + music.links = + lib.mkBefore [ (mopidyLink // { text = "Mopidy server"; }) ]; }; }) ]); diff --git a/configs/home-manager/foo-dogsquared/modules/setups/research.nix b/configs/home-manager/foo-dogsquared/modules/setups/research.nix index e2162ebd..fe3dda12 100644 --- a/configs/home-manager/foo-dogsquared/modules/setups/research.nix +++ b/configs/home-manager/foo-dogsquared/modules/setups/research.nix @@ -10,29 +10,37 @@ let # `services.gallery-dl`, and `services.archivebox`. mkJobs = { extraArgs ? [ ], db }: let - days = [ "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" ]; - categories = lib.zipListsWith - (index: category: { inherit index; data = category; }) - (lib.lists.range 1 (lib.length (lib.attrValues db))) - (lib.mapAttrsToList (name: value: { inherit name; inherit (value) subscriptions extraArgs; }) db); - jobsList = builtins.map - (category: - let - jobExtraArgs = lib.attrByPath [ "data" "extraArgs" ] [ ] category; - in - { - name = category.data.name; - value = { - extraArgs = extraArgs ++ jobExtraArgs; - urls = builtins.map (subscription: subscription.url) category.data.subscriptions; - startAt = lib.elemAt days (lib.mod category.index (lib.length days)); - }; - }) - categories; - in - lib.listToAttrs jobsList; -in -{ + days = [ + "Monday" + "Tuesday" + "Wednesday" + "Thursday" + "Friday" + "Saturday" + "Sunday" + ]; + categories = lib.zipListsWith (index: category: { + inherit index; + data = category; + }) (lib.lists.range 1 (lib.length (lib.attrValues db))) + (lib.mapAttrsToList (name: value: { + inherit name; + inherit (value) subscriptions extraArgs; + }) db); + jobsList = builtins.map (category: + let jobExtraArgs = lib.attrByPath [ "data" "extraArgs" ] [ ] category; + in { + name = category.data.name; + value = { + extraArgs = extraArgs ++ jobExtraArgs; + urls = builtins.map (subscription: subscription.url) + category.data.subscriptions; + startAt = + lib.elemAt days (lib.mod category.index (lib.length days)); + }; + }) categories; + in lib.listToAttrs jobsList; +in { options.users.foo-dogsquared.setups.research.enable = lib.mkEnableOption "foo-dogsquared's usual toolbelt for research"; @@ -60,7 +68,9 @@ in services.syncthing = { enable = true; extraOptions = [ - "--gui-address=http://localhost:${builtins.toString config.state.ports.syncthing.value}" + "--gui-address=http://localhost:${ + builtins.toString config.state.ports.syncthing.value + }" ]; }; @@ -70,7 +80,9 @@ in users.foo-dogsquared.programs.custom-homepage.sections.services.links = lib.singleton { - url = "http://localhost:${builtins.toString config.state.ports.syncthing.value}"; + url = "http://localhost:${ + builtins.toString config.state.ports.syncthing.value + }"; text = "Local sync server"; }; } diff --git a/configs/home-manager/nixos/default.nix b/configs/home-manager/nixos/default.nix index 72d39fde..3e2d3b50 100644 --- a/configs/home-manager/nixos/default.nix +++ b/configs/home-manager/nixos/default.nix @@ -24,13 +24,7 @@ programs.bash = { enable = true; historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; - historyIgnore = [ - "cd" - "exit" - "lf" - "ls" - "nvim" - ]; + historyIgnore = [ "cd" "exit" "lf" "ls" "nvim" ]; }; home.stateVersion = "23.11"; diff --git a/configs/home-manager/nixos/modules/default.nix b/configs/home-manager/nixos/modules/default.nix index f9818093..942803d5 100644 --- a/configs/home-manager/nixos/modules/default.nix +++ b/configs/home-manager/nixos/modules/default.nix @@ -1,5 +1 @@ -{ - imports = [ - ./programs/terminal-multiplexer.nix - ]; -} +{ imports = [ ./programs/terminal-multiplexer.nix ]; } diff --git a/configs/home-manager/nixos/modules/programs/terminal-multiplexer.nix b/configs/home-manager/nixos/modules/programs/terminal-multiplexer.nix index b374a554..71cec771 100644 --- a/configs/home-manager/nixos/modules/programs/terminal-multiplexer.nix +++ b/configs/home-manager/nixos/modules/programs/terminal-multiplexer.nix @@ -4,8 +4,7 @@ let userCfg = config.users.nixos; cfg = userCfg.programs.terminal-multiplexer; -in -{ +in { options.users.nixos.programs.terminal-multiplexer.enable = lib.mkEnableOption "terminal multiplexer"; diff --git a/configs/home-manager/plover/default.nix b/configs/home-manager/plover/default.nix index cddea93d..fd8392be 100644 --- a/configs/home-manager/plover/default.nix +++ b/configs/home-manager/plover/default.nix @@ -2,23 +2,13 @@ { config, lib, pkgs, ... }: { - home.packages = with pkgs; [ - glances - wireshark-cli - jq - ]; + home.packages = with pkgs; [ glances wireshark-cli jq ]; # My user shell of choice because I'm not a hipster. programs.bash = { enable = true; historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; - historyIgnore = [ - "cd" - "exit" - "lf" - "ls" - "nvim" - ]; + historyIgnore = [ "cd" "exit" "lf" "ls" "nvim" ]; }; suites = { @@ -39,10 +29,7 @@ services.bleachbit = { enable = true; - cleaners = [ - "bash.history" - "vim.history" - ]; + cleaners = [ "bash.history" "vim.history" ]; startAt = "weekly"; }; diff --git a/configs/nixos/_users/admin/default.nix b/configs/nixos/_users/admin/default.nix index 459c90d5..dff7ce0f 100644 --- a/configs/nixos/_users/admin/default.nix +++ b/configs/nixos/_users/admin/default.nix @@ -1,10 +1,8 @@ # Mainly used for managing the installations with deploy-rs. { config, lib, pkgs, ... }: -let - name = "admin"; -in -{ +let name = "admin"; +in { users.users.${name} = { description = "The administrator account for the servers."; isNormalUser = true; diff --git a/configs/nixos/_users/nixos/default.nix b/configs/nixos/_users/nixos/default.nix index c85ac0ff..79c0a752 100644 --- a/configs/nixos/_users/nixos/default.nix +++ b/configs/nixos/_users/nixos/default.nix @@ -24,10 +24,8 @@ sandbox = true; # Set several binary caches. - substituters = [ - "https://cache.nixos.org/" - "https://nix-community.cachix.org" - ]; + substituters = + [ "https://cache.nixos.org/" "https://nix-community.cachix.org" ]; trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; diff --git a/configs/nixos/_users/plover/default.nix b/configs/nixos/_users/plover/default.nix index ed917f58..0976a81b 100644 --- a/configs/nixos/_users/plover/default.nix +++ b/configs/nixos/_users/plover/default.nix @@ -4,11 +4,11 @@ let user = "plover"; homeManagerUser = foodogsquaredUtils.getConfig "home-manager" user; -in -{ +in { users.users.${user} = { home = "/home/${user}"; - hashedPassword = "$y$j9T$43ExH5GLbEGwgnNGhmcTD/$qXoZE5Cm9O2Z3zMM/VyCZ18qN2Hc9.KvCnVz6tmjVVD"; + hashedPassword = + "$y$j9T$43ExH5GLbEGwgnNGhmcTD/$qXoZE5Cm9O2Z3zMM/VyCZ18qN2Hc9.KvCnVz6tmjVVD"; extraGroups = [ "wheel" "kanidm" ]; useDefaultShell = true; isNormalUser = true; @@ -24,7 +24,5 @@ in ]; }; - home-manager.users.${user} = { - imports = [ homeManagerUser ]; - }; + home-manager.users.${user} = { imports = [ homeManagerUser ]; }; } diff --git a/configs/nixos/bootstrap/default.nix b/configs/nixos/bootstrap/default.nix index 77a69bef..a7d70199 100644 --- a/configs/nixos/bootstrap/default.nix +++ b/configs/nixos/bootstrap/default.nix @@ -6,9 +6,7 @@ # # This means, there will be a "nixos" user among other things. { - imports = [ - "${foodogsquaredModulesPath}/profiles/installer.nix" - ]; + imports = [ "${foodogsquaredModulesPath}/profiles/installer.nix" ]; config = lib.mkMerge [ { diff --git a/configs/nixos/graphical-installer/default.nix b/configs/nixos/graphical-installer/default.nix index 95a9c224..15acefa9 100644 --- a/configs/nixos/graphical-installer/default.nix +++ b/configs/nixos/graphical-installer/default.nix @@ -1,8 +1,4 @@ -{ lib -, config -, pkgs -, foodogsquaredLib -, foodogsquaredUtils +{ lib, config, pkgs, foodogsquaredLib, foodogsquaredUtils , foodogsquaredModulesPath , ... }: @@ -34,9 +30,7 @@ # closure size smaller. workflows = { enable = [ "a-happy-gnome" ]; - workflows.a-happy-gnome = { - extraApps = lib.mkForce [ ]; - }; + workflows.a-happy-gnome = { extraApps = lib.mkForce [ ]; }; }; # Install the web browser of course. What would be a graphical installer @@ -63,8 +57,7 @@ system.stateVersion = "23.11"; } - (lib.mkIf - (foodogsquaredLib.nixos.isFormat config "isoImage") { + (lib.mkIf (foodogsquaredLib.nixos.isFormat config "isoImage") { isoImage = { isoBaseName = config.networking.hostName; edition = "a-happy-gnome"; diff --git a/configs/nixos/ni/config/nixpkgs/config.nix b/configs/nixos/ni/config/nixpkgs/config.nix index 1dd1750a..69baf106 100644 --- a/configs/nixos/ni/config/nixpkgs/config.nix +++ b/configs/nixos/ni/config/nixpkgs/config.nix @@ -1,3 +1 @@ -{ - allowUnfree = true; -} +{ allowUnfree = true; } diff --git a/configs/nixos/ni/disko.nix b/configs/nixos/ni/disko.nix index c5864bc7..7e65114d 100644 --- a/configs/nixos/ni/disko.nix +++ b/configs/nixos/ni/disko.nix @@ -1,72 +1,70 @@ { primaryDisk ? "/dev/nvme0n1", config, lib, ... }: { - disko.devices = lib.mkMerge [ - { - disk."${config.networking.hostName}-primary" = { - device = primaryDisk; - type = "disk"; - content = { - type = "gpt"; - partitions = { - # You can't really have a btrfs-layered boot so this'll have to do. - ESP = { - priority = 1; - start = "0"; - end = "512MiB"; - type = "EF00"; - content = { - type = "filesystem"; - mountpoint = "/boot"; - format = "vfat"; - }; + disko.devices = lib.mkMerge [{ + disk."${config.networking.hostName}-primary" = { + device = primaryDisk; + type = "disk"; + content = { + type = "gpt"; + partitions = { + # You can't really have a btrfs-layered boot so this'll have to do. + ESP = { + priority = 1; + start = "0"; + end = "512MiB"; + type = "EF00"; + content = { + type = "filesystem"; + mountpoint = "/boot"; + format = "vfat"; }; + }; - swap = { - start = "-8GiB"; - end = "-0"; - type = "8200"; - content = { - type = "swap"; - randomEncryption = true; - }; + swap = { + start = "-8GiB"; + end = "-0"; + type = "8200"; + content = { + type = "swap"; + randomEncryption = true; }; + }; - root = { - size = "100%"; - type = "8300"; - content = { - type = "btrfs"; - extraArgs = [ "-f" ]; + root = { + size = "100%"; + type = "8300"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; - subvolumes = lib.mkMerge [ - { - "/root" = { - mountOptions = [ "compress=zstd" ]; - mountpoint = "/"; - }; - "/home" = { - mountOptions = [ "compress=zstd" ]; - mountpoint = "/home"; - }; - "/nix" = { - mountOptions = [ "compress=zstd" "noatime" "noacl" ]; - mountpoint = "/nix"; - }; - } + subvolumes = lib.mkMerge [ + { + "/root" = { + mountOptions = [ "compress=zstd" ]; + mountpoint = "/"; + }; + "/home" = { + mountOptions = [ "compress=zstd" ]; + mountpoint = "/home"; + }; + "/nix" = { + mountOptions = [ "compress=zstd" "noatime" "noacl" ]; + mountpoint = "/nix"; + }; + } - (lib.mkIf config.services.guix.enable { - "/gnu" = { - mountOptions = [ "compress=zstd" "noatime" "noacl" ]; - mountpoint = "/gnu"; - }; - }) - ]; - }; + (lib.mkIf config.services.guix.enable { + "/gnu" = { + mountOptions = [ "compress=zstd" "noatime" "noacl" ]; + mountpoint = "/gnu"; + }; + }) + ]; }; }; }; }; - } - ]; + }; + }]; } diff --git a/configs/nixos/ni/hardware-configuration.nix b/configs/nixos/ni/hardware-configuration.nix index 3d1236b8..640acd82 100644 --- a/configs/nixos/ni/hardware-configuration.nix +++ b/configs/nixos/ni/hardware-configuration.nix @@ -1,12 +1,11 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = [ - (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; boot.kernelPackages = pkgs.linuxKernel.packages.linux_6_12; - boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usbhid" "uas" "sd_mod" ]; + boot.initrd.availableKernelModules = + [ "nvme" "xhci_pci" "thunderbolt" "usbhid" "uas" "sd_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; diff --git a/configs/nixos/ni/modules/hardware/qol.nix b/configs/nixos/ni/modules/hardware/qol.nix index 5bc6e263..eed36c28 100644 --- a/configs/nixos/ni/modules/hardware/qol.nix +++ b/configs/nixos/ni/modules/hardware/qol.nix @@ -4,8 +4,7 @@ let hostCfg = config.hosts.ni; cfg = hostCfg.hardware.qol; -in -{ +in { options.hosts.ni.hardware.qol.enable = lib.mkEnableOption "quality-of-life hardware features"; @@ -17,10 +16,7 @@ in services.printing = { enable = true; browsing = true; - drivers = with pkgs; [ - gutenprint - splix - ]; + drivers = with pkgs; [ gutenprint splix ]; }; # Extend the life of an SSD. diff --git a/configs/nixos/ni/modules/networking/setup.nix b/configs/nixos/ni/modules/networking/setup.nix index 83f35071..13165721 100644 --- a/configs/nixos/ni/modules/networking/setup.nix +++ b/configs/nixos/ni/modules/networking/setup.nix @@ -3,8 +3,7 @@ let hostCfg = config.hosts.ni; cfg = hostCfg.networking; -in -{ +in { options.hosts.ni.networking = { enable = lib.mkEnableOption "networking setup"; @@ -31,9 +30,7 @@ in ::: ''; default = - if config.networking.useNetworkd - then "networkd" - else "networkmanager"; + if config.networking.useNetworkd then "networkd" else "networkmanager"; defaultText = '' When networkd is enabled, `networkd`, otherwise `networkmanager` as the general fallback value. @@ -54,11 +51,8 @@ in }; # Add these timeservers. - networking.timeServers = lib.mkBefore [ - "ntp.nict.jp" - "time.nist.gov" - "time.facebook.com" - ]; + networking.timeServers = + lib.mkBefore [ "ntp.nict.jp" "time.nist.gov" "time.facebook.com" ]; # Put on your cloak, kid. suites.vpn.personal.enable = true; @@ -148,9 +142,7 @@ in dhcp = lib.mkIf (config.networking.dhcpcd.enable) "dhcpcd"; } - (lib.mkIf config.services.resolved.enable { - dns = "systemd-resolved"; - }) + (lib.mkIf config.services.resolved.enable { dns = "systemd-resolved"; }) ]; # We'll configure individual network interfaces to use DHCP since it can diff --git a/configs/nixos/ni/modules/networking/wireguard.nix b/configs/nixos/ni/modules/networking/wireguard.nix index 834cdbb4..2d82e609 100644 --- a/configs/nixos/ni/modules/networking/wireguard.nix +++ b/configs/nixos/ni/modules/networking/wireguard.nix @@ -8,14 +8,10 @@ let inherit (builtins) toString; inherit (import ../../../plover/modules/hardware/networks.nix) - interfaces - wireguardPort - wireguardPeers; + interfaces wireguardPort wireguardPeers; - wireguardAllowedIPs = [ - "${interfaces.lan.IPv4.address}/16" - "${interfaces.lan.IPv6.address}/64" - ]; + wireguardAllowedIPs = + [ "${interfaces.lan.IPv4.address}/16" "${interfaces.lan.IPv6.address}/64" ]; wireguardIFName = "wireguard0"; internalDomains = [ @@ -23,19 +19,20 @@ let "~0.27.172.in-addr.arpa" "~0.28.172.in-addr.arpa" ]; -in -{ - options.hosts.ni.networking.wireguard.enable = lib.mkEnableOption "Wireguard setup"; +in { + options.hosts.ni.networking.wireguard.enable = + lib.mkEnableOption "Wireguard setup"; config = lib.mkIf (hostCfg.networking.enable && cfg.enable) (lib.mkMerge [ { environment.systemPackages = with pkgs; [ wireguard-tools ]; networking.firewall.allowedUDPPorts = [ wireguardPort ]; - sops.secrets = foodogsquaredLib.sops-nix.getSecrets ../../secrets/secrets.yaml { - "wireguard/private-key" = { }; - "wireguard/preshared-keys/plover" = { }; - "wireguard/preshared-keys/phone" = { }; - }; + sops.secrets = + foodogsquaredLib.sops-nix.getSecrets ../../secrets/secrets.yaml { + "wireguard/private-key" = { }; + "wireguard/preshared-keys/plover" = { }; + "wireguard/preshared-keys/phone" = { }; + }; } (lib.mkIf (networkSetup == "networkmanager") { @@ -60,35 +57,36 @@ in privateKeyFile = config.sops.secrets."wireguard/private-key".path; listenPort = wireguardPort; dns = with interfaces.lan; [ IPv4.address IPv6.address ]; - postUp = - let - resolvectl = "${lib.getBin pkgs.systemd}/bin/resolvectl"; - in - '' - ${resolvectl} domain ${wireguardIFName} ${lib.concatStringsSep " " internalDomains} - ${resolvectl} dnssec ${wireguardIFName} no - ''; + postUp = let resolvectl = "${lib.getBin pkgs.systemd}/bin/resolvectl"; + in '' + ${resolvectl} domain ${wireguardIFName} ${ + lib.concatStringsSep " " internalDomains + } + ${resolvectl} dnssec ${wireguardIFName} no + ''; - address = with wireguardPeers.desktop; [ - "${IPv4}/32" - "${IPv6}/128" - ]; + address = with wireguardPeers.desktop; [ "${IPv4}/32" "${IPv6}/128" ]; # Take note wg-quick doesn't trim the files so we have to trim it ourselves. peers = [ # The "server" peer. { - publicKey = lib.removeSuffix "\n" (lib.readFile ../../../plover/files/wireguard/wireguard-public-key-plover); - presharedKeyFile = config.sops.secrets."wireguard/preshared-keys/plover".path; + publicKey = lib.removeSuffix "\n" (lib.readFile + ../../../plover/files/wireguard/wireguard-public-key-plover); + presharedKeyFile = + config.sops.secrets."wireguard/preshared-keys/plover".path; allowedIPs = wireguardAllowedIPs; - endpoint = "${interfaces.wan.IPv4.address}:${toString wireguardPort}"; + endpoint = + "${interfaces.wan.IPv4.address}:${toString wireguardPort}"; persistentKeepalive = 25; } # The "phone" peer. { - publicKey = lib.removeSuffix "\n" (lib.readFile ../../../plover/files/wireguard/wireguard-public-key-phone); - presharedKeyFile = config.sops.secrets."wireguard/preshared-keys/phone".path; + publicKey = lib.removeSuffix "\n" (lib.readFile + ../../../plover/files/wireguard/wireguard-public-key-phone); + presharedKeyFile = + config.sops.secrets."wireguard/preshared-keys/phone".path; allowedIPs = wireguardAllowedIPs; } ]; @@ -97,22 +95,21 @@ in (lib.mkIf (networkSetup == "networkd") { # Just apply the appropriate permissions for systemd-networkd. - sops.secrets = - let - systemdNetworkFileAttrs = { - group = config.users.users.systemd-network.group; - reloadUnits = [ "systemd-networkd.service" ]; - mode = "0640"; - }; - applySystemdAttr = secretPaths: lib.listToAttrs - (builtins.map (path: lib.nameValuePair path systemdNetworkFileAttrs)) - secretPaths; - in - applySystemdAttr [ - "wireguard/private-key" - "wireguard/preshared-keys/phone" - "wireguard/preshared-keys/plover" - ]; + sops.secrets = let + systemdNetworkFileAttrs = { + group = config.users.users.systemd-network.group; + reloadUnits = [ "systemd-networkd.service" ]; + mode = "0640"; + }; + applySystemdAttr = secretPaths: + lib.listToAttrs + (builtins.map (path: lib.nameValuePair path systemdNetworkFileAttrs)) + secretPaths; + in applySystemdAttr [ + "wireguard/private-key" + "wireguard/preshared-keys/phone" + "wireguard/preshared-keys/plover" + ]; systemd.network = { netdevs."99-${wireguardIFName}" = { @@ -129,17 +126,22 @@ in wireguardPeers = [ # The "server" peer. { - PublicKey = lib.readFile ../../../plover/files/wireguard/wireguard-public-key-plover; - PresharedKeyFile = config.sops.secrets."wireguard/preshared-keys/plover".path; + PublicKey = lib.readFile + ../../../plover/files/wireguard/wireguard-public-key-plover; + PresharedKeyFile = + config.sops.secrets."wireguard/preshared-keys/plover".path; AllowedIPs = lib.concatStringsSep "," wireguardAllowedIPs; - Endpoint = "${interfaces.wan.IPv4.address}:${toString wireguardPort}"; + Endpoint = + "${interfaces.wan.IPv4.address}:${toString wireguardPort}"; PersistentKeepalive = 25; } # The "phone" peer. { - PublicKey = lib.readFile ../../../plover/files/wireguard/wireguard-public-key-phone; - PresharedKeyFile = config.sops.secrets."wireguard/preshared-keys/phone".path; + PublicKey = lib.readFile + ../../../plover/files/wireguard/wireguard-public-key-phone; + PresharedKeyFile = + config.sops.secrets."wireguard/preshared-keys/phone".path; AllowedIPs = lib.concatStringsSep "," wireguardAllowedIPs; } ]; @@ -148,10 +150,7 @@ in networks."99-${wireguardIFName}" = { matchConfig.Name = wireguardIFName; - address = with wireguardPeers.desktop; [ - "${IPv4}/32" - "${IPv6}/128" - ]; + address = with wireguardPeers.desktop; [ "${IPv4}/32" "${IPv6}/128" ]; dns = with interfaces.lan; [ IPv4.address IPv6.address ]; domains = internalDomains; diff --git a/configs/nixos/ni/modules/services/backup/default.nix b/configs/nixos/ni/modules/services/backup/default.nix index ba1ee013..3b63a652 100644 --- a/configs/nixos/ni/modules/services/backup/default.nix +++ b/configs/nixos/ni/modules/services/backup/default.nix @@ -6,53 +6,49 @@ let cfg = hostCfg.services.backup; borgJobCommonSetting = { patterns ? [ ], passCommand, ... }@args: - let - args' = lib.attrsets.removeAttrs args [ "patterns" "passCommand" ]; - in - { - compression = "zstd,12"; - dateFormat = "+%F-%H-%M-%S-%z"; - doInit = false; - encryption = { - inherit passCommand; - mode = "repokey-blake2"; - }; - extraCreateArgs = lib.concatStringsSep " " - (builtins.map (patternFile: "--patterns-from ${patternFile}") patterns); - extraInitArgs = "--make-parent-dirs"; - - # We're emptying them since we're specifying them all through the patterns file. - paths = lib.mkForce [ ]; - - persistentTimer = true; - preHook = '' - extraCreateArgs="$extraCreateArgs --exclude-if-present .nobackup" - extraCreateArgs="$extraCreateArgs --stats" - ''; - prune = { - keep = { - within = "1d"; - hourly = 8; - daily = 30; - weekly = 4; - monthly = 6; - yearly = 3; + let args' = lib.attrsets.removeAttrs args [ "patterns" "passCommand" ]; + in { + compression = "zstd,12"; + dateFormat = "+%F-%H-%M-%S-%z"; + doInit = false; + encryption = { + inherit passCommand; + mode = "repokey-blake2"; }; - }; - } // args'; + extraCreateArgs = lib.concatStringsSep " " + (builtins.map (patternFile: "--patterns-from ${patternFile}") patterns); + extraInitArgs = "--make-parent-dirs"; + + # We're emptying them since we're specifying them all through the patterns file. + paths = lib.mkForce [ ]; + + persistentTimer = true; + preHook = '' + extraCreateArgs="$extraCreateArgs --exclude-if-present .nobackup" + extraCreateArgs="$extraCreateArgs --stats" + ''; + prune = { + keep = { + within = "1d"; + hourly = 8; + daily = 30; + weekly = 4; + monthly = 6; + yearly = 3; + }; + }; + } // args'; hetzner-boxes-user = "u332477"; hetzner-boxes-server = "${hetzner-boxes-user}.your-storagebox.de"; pathPrefix = "borg-backup"; -in -{ +in { options.hosts.ni.services.backup.enable = lib.mkEnableOption "backup setup with BorgBackup"; config = lib.mkIf cfg.enable { - sops.secrets = foodogsquaredLib.sops-nix.getSecrets - ./secrets.yaml + sops.secrets = foodogsquaredLib.sops-nix.getSecrets ./secrets.yaml (foodogsquaredLib.sops-nix.attachSopsPathPrefix pathPrefix { "patterns/home" = { }; "patterns/root" = { }; @@ -63,9 +59,7 @@ in "repos/hetzner-box/ssh-key" = { }; }); - suites.filesystem.setups = { - laptop-ssd.enable = true; - }; + suites.filesystem.setups = { laptop-ssd.enable = true; }; services.borgbackup.jobs = { local-external-storage = borgJobCommonSetting { @@ -73,21 +67,27 @@ in secrets."${pathPrefix}/patterns/root".path secrets."${pathPrefix}/patterns/keys".path ]; - passCommand = "cat ${config.sops.secrets."${pathPrefix}/repos/external-hdd/password".path}"; + passCommand = "cat ${ + config.sops.secrets."${pathPrefix}/repos/external-hdd/password".path + }"; removableDevice = true; doInit = true; repo = "${config.state.paths.laptop-ssd}/Backups"; }; remote-backup-hetzner-box = borgJobCommonSetting { - patterns = with config.sops; [ - secrets."${pathPrefix}/patterns/home".path - ]; - passCommand = "cat ${config.sops.secrets."${pathPrefix}/repos/hetzner-box/password".path}"; + patterns = with config.sops; + [ secrets."${pathPrefix}/patterns/home".path ]; + passCommand = "cat ${ + config.sops.secrets."${pathPrefix}/repos/hetzner-box/password".path + }"; doInit = true; - repo = "ssh://${hetzner-boxes-user}@${hetzner-boxes-server}:23/./borg/desktop/ni"; + repo = + "ssh://${hetzner-boxes-user}@${hetzner-boxes-server}:23/./borg/desktop/ni"; startAt = "04:30"; - environment.BORG_RSH = "ssh -i ${config.sops.secrets."${pathPrefix}/repos/hetzner-box/ssh-key".path}"; + environment.BORG_RSH = "ssh -i ${ + config.sops.secrets."${pathPrefix}/repos/hetzner-box/ssh-key".path + }"; }; }; }; diff --git a/configs/nixos/ni/modules/services/dns-server/default.nix b/configs/nixos/ni/modules/services/dns-server/default.nix index 1ae536fd..f5c2cdee 100644 --- a/configs/nixos/ni/modules/services/dns-server/default.nix +++ b/configs/nixos/ni/modules/services/dns-server/default.nix @@ -3,8 +3,7 @@ let hostCfg = config.hosts.ni; cfg = hostCfg.services.dns-server; -in -{ +in { options.hosts.ni.services.dns-server.enable = lib.mkEnableOption "preferred DNS server"; diff --git a/configs/nixos/ni/modules/services/download-media/default.nix b/configs/nixos/ni/modules/services/download-media/default.nix index 589b57d3..6398fa41 100644 --- a/configs/nixos/ni/modules/services/download-media/default.nix +++ b/configs/nixos/ni/modules/services/download-media/default.nix @@ -11,197 +11,202 @@ let newgrounds = name: "https://${name}.newgrounds.com"; pathPrefix = "download-media"; -in -{ +in { options.hosts.ni.services.download-media.enable = lib.mkEnableOption "automated multimedia download services"; - config = lib.mkIf cfg.enable ( - let - ytdlpArgs = [ - # No overwriting of videos and related files. - "--no-force-overwrites" + config = lib.mkIf cfg.enable (let + ytdlpArgs = [ + # No overwriting of videos and related files. + "--no-force-overwrites" - # Embed metadata in the file. - "--write-info-json" + # Embed metadata in the file. + "--write-info-json" - # Embed chapter markers, if possible. - "--embed-chapters" + # Embed chapter markers, if possible. + "--embed-chapters" - # Write the subtitle file with the preferred languages. - "--write-subs" - "--sub-langs" "en.*,ja,ko,zh.*,fr,pt.*" + # Write the subtitle file with the preferred languages. + "--write-subs" + "--sub-langs" + "en.*,ja,ko,zh.*,fr,pt.*" - # Write the description in a separate file. - "--write-description" + # Write the description in a separate file. + "--write-description" - # The global output for all of the jobs. - "--output" - "%(uploader,artist,creator|Unknown)s/%(release_date>%F,upload_date>%F|Unknown)s-%(title)s.%(ext)s" + # The global output for all of the jobs. + "--output" + "%(uploader,artist,creator|Unknown)s/%(release_date>%F,upload_date>%F|Unknown)s-%(title)s.%(ext)s" - # Select only the most optimal format for my usecases. - "--format" - "(webm,mkv,mp4)[height<=?1280]" + # Select only the most optimal format for my usecases. + "--format" + "(webm,mkv,mp4)[height<=?1280]" - # Prefer MKV whenever possible for video formats. - "--merge-output-format" "mkv" + # Prefer MKV whenever possible for video formats. + "--merge-output-format" + "mkv" - # Don't download any videos that are originally live streams. - "--match-filters" "!was_live" + # Don't download any videos that are originally live streams. + "--match-filters" + "!was_live" - "--audio-quality" "1" + "--audio-quality" + "1" - # Not much error since it will always fail. - "--no-abort-on-error" - "--ignore-errors" - "--ignore-no-formats-error" + # Not much error since it will always fail. + "--no-abort-on-error" + "--ignore-errors" + "--ignore-no-formats-error" + ]; + + galleryDlArgs = [ + # Write metadata to separate JSON files. + "--write-metadata" + + # The config file that contains the secrets for various services. + # We're putting as a separate config file instead of configuring it + # in the service properly since secrets decrypted by sops-nix cannot + # be read in Nix. + ]; + + # Given an attribute set of jobs that contains a list of objects with + # their names and URL, create an attrset suitable for declaring the + # archiving jobs of several services for `services.yt-dlp`, + # `services.gallery-dl`, and `services.archivebox`. + mkJobs = { extraArgs ? [ ], db }: + let + days = [ + "Monday" + "Tuesday" + "Wednesday" + "Thursday" + "Friday" + "Saturday" + "Sunday" + ]; + categories = lib.zipListsWith (index: category: { + inherit index; + data = category; + }) (lib.lists.range 1 (lib.length (lib.attrValues db))) + (lib.mapAttrsToList (name: value: { + inherit name; + inherit (value) subscriptions extraArgs; + }) db); + jobsList = builtins.map (category: + let jobExtraArgs = lib.attrByPath [ "data" "extraArgs" ] [ ] category; + in { + name = category.data.name; + value = { + extraArgs = extraArgs ++ jobExtraArgs; + urls = builtins.map (subscription: subscription.url) + category.data.subscriptions; + startAt = + lib.elemAt days (lib.mod category.index (lib.length days)); + }; + }) categories; + in lib.listToAttrs jobsList; + in { + suites.filesystem.setups.archive.enable = true; + + services.yt-dlp = { + enable = true; + downloadPath = "${mountName}/yt-dlp-service"; + + # This is applied on all jobs. It is best to be minimal as much as + # possible for this. + extraArgs = ytdlpArgs ++ [ + # Make a global list of successfully downloaded videos as a cache for yt-dlp. + "--download-archive" + "videos" ]; - galleryDlArgs = [ - # Write metadata to separate JSON files. - "--write-metadata" + jobs = mkJobs { + extraArgs = [ "--playlist-end" "20" ]; + db = lib.importJSON ./data/jobs.yt-dlp.json; + }; + }; - # The config file that contains the secrets for various services. - # We're putting as a separate config file instead of configuring it - # in the service properly since secrets decrypted by sops-nix cannot - # be read in Nix. + services.archivebox = { + enable = true; + webserver.enable = true; + + jobs = mkJobs { db = lib.importJSON ./data/jobs.archivebox.json; } // { + computer = { + urls = [ + "https://blog.mozilla.org/en/feed/" + "https://distill.pub/rss.xml" + "https://drewdevault.com/blog/index.xml" + "https://fasterthanli.me/index.xml" + "https://jvns.ca/atom.xml" + "https://www.bytelab.codes/rss/" + "https://www.collabora.com/feed" + "https://www.jntrnr.com/atom.xml" + "https://yosoygames.com.ar/wp/?feed=rss" + "https://simblob.blogspot.com/feeds/posts/default" + ]; + startAt = "weekly"; + }; + }; + }; + + services.gallery-dl = { + enable = true; + downloadPath = "${mountName}/gallery-dl-service"; + + extraArgs = galleryDlArgs ++ [ + # Record all downloaded files in an archive file. + "--download-archive" + "${config.services.gallery-dl.downloadPath}/photos" ]; - # Given an attribute set of jobs that contains a list of objects with - # their names and URL, create an attrset suitable for declaring the - # archiving jobs of several services for `services.yt-dlp`, - # `services.gallery-dl`, and `services.archivebox`. - mkJobs = { extraArgs ? [ ], db }: - let - days = [ "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" ]; - categories = lib.zipListsWith - (index: category: { inherit index; data = category; }) - (lib.lists.range 1 (lib.length (lib.attrValues db))) - (lib.mapAttrsToList (name: value: { inherit name; inherit (value) subscriptions extraArgs; }) db); - jobsList = builtins.map - (category: - let - jobExtraArgs = lib.attrByPath [ "data" "extraArgs" ] [ ] category; - in - { - name = category.data.name; - value = { - extraArgs = extraArgs ++ jobExtraArgs; - urls = builtins.map (subscription: subscription.url) category.data.subscriptions; - startAt = lib.elemAt days (lib.mod category.index (lib.length days)); - }; - }) - categories; - in - lib.listToAttrs jobsList; - in - { - suites.filesystem.setups.archive.enable = true; + settings.extractor = { filename = "{date:%F}-{title}.{extension}"; }; - services.yt-dlp = { - enable = true; - downloadPath = "${mountName}/yt-dlp-service"; - - # This is applied on all jobs. It is best to be minimal as much as - # possible for this. - extraArgs = ytdlpArgs ++ [ - # Make a global list of successfully downloaded videos as a cache for yt-dlp. - "--download-archive" "videos" - ]; - - jobs = mkJobs { - extraArgs = [ "--playlist-end" "20" ]; - db = lib.importJSON ./data/jobs.yt-dlp.json; + jobs = { + arts = { + urls = [ + (deviantArt "xezeno") # Xezeno + (deviantArt "jenzee") # JenZee + (deviantArt "silverponteo") # hurrakka + #"https://www.pixiv.net/en/users/60562229" # Ravioli + (artStation "dominikmayerart") # Dominik Mayer + (artStation "archiewhitehead") # Archie Whitehead + (artStation "kuvshinov_ilya") # Ilya Kuvshinov + (artStation "meiipng") # Meiiart + (artStation "bassem_wageeh") # Bassem wageeh + (artStation "ocellusart") # Ocellus + (artStation "jordanparrin") # Jordan Parrin + (artStation "blazporenta") # Blaz Porenta + (artStation "an_na") # Anya Mozharovska + (artStation "dllxtt") # Mykhail Klymenko + (artStation "nicwilliams") # Nic Williams + (artStation "aaconcept") # Andrew An + (artStation "aliena85") # Mandy Jurgens + (artStation "666kart") # Kan Liu + (artStation "angryangryasian") # David Liu + (artStation "mikedilonardo") # Michael Di Lonardo + (artStation "karlschecht") # Karl Schecht + (artStation "12oyraj") # Royraj Vichaidit + (artStation "jcru3d") # Jan Cruz + (artStation "wookun") # Sangtaek Woo + (newgrounds "hyperjerk") # HyperJerk + ]; + startAt = "weekly"; }; }; + }; - services.archivebox = { - enable = true; - webserver.enable = true; - - jobs = mkJobs - { - db = lib.importJSON ./data/jobs.archivebox.json; - } // { - computer = { - urls = [ - "https://blog.mozilla.org/en/feed/" - "https://distill.pub/rss.xml" - "https://drewdevault.com/blog/index.xml" - "https://fasterthanli.me/index.xml" - "https://jvns.ca/atom.xml" - "https://www.bytelab.codes/rss/" - "https://www.collabora.com/feed" - "https://www.jntrnr.com/atom.xml" - "https://yosoygames.com.ar/wp/?feed=rss" - "https://simblob.blogspot.com/feeds/posts/default" - ]; - startAt = "weekly"; - }; - }; + wrapper-manager.packages.download-media-variants = { + wrappers."yt-dlp-${pathPrefix}" = { + arg0 = lib.getExe' config.services.yt-dlp.package "yt-dlp"; + prependArgs = ytdlpArgs; }; - services.gallery-dl = { - enable = true; - downloadPath = "${mountName}/gallery-dl-service"; - - extraArgs = galleryDlArgs ++ [ - # Record all downloaded files in an archive file. - "--download-archive" - "${config.services.gallery-dl.downloadPath}/photos" - ]; - - settings.extractor = { - filename = "{date:%F}-{title}.{extension}"; - }; - - jobs = { - arts = { - urls = [ - (deviantArt "xezeno") # Xezeno - (deviantArt "jenzee") # JenZee - (deviantArt "silverponteo") # hurrakka - #"https://www.pixiv.net/en/users/60562229" # Ravioli - (artStation "dominikmayerart") # Dominik Mayer - (artStation "archiewhitehead") # Archie Whitehead - (artStation "kuvshinov_ilya") # Ilya Kuvshinov - (artStation "meiipng") # Meiiart - (artStation "bassem_wageeh") # Bassem wageeh - (artStation "ocellusart") # Ocellus - (artStation "jordanparrin") # Jordan Parrin - (artStation "blazporenta") # Blaz Porenta - (artStation "an_na") # Anya Mozharovska - (artStation "dllxtt") # Mykhail Klymenko - (artStation "nicwilliams") # Nic Williams - (artStation "aaconcept") # Andrew An - (artStation "aliena85") # Mandy Jurgens - (artStation "666kart") # Kan Liu - (artStation "angryangryasian") # David Liu - (artStation "mikedilonardo") # Michael Di Lonardo - (artStation "karlschecht") # Karl Schecht - (artStation "12oyraj") # Royraj Vichaidit - (artStation "jcru3d") # Jan Cruz - (artStation "wookun") # Sangtaek Woo - (newgrounds "hyperjerk") # HyperJerk - ]; - startAt = "weekly"; - }; - }; + wrappers."gallery-dl-${pathPrefix}" = { + arg0 = lib.getExe' config.services.gallery-dl.package "gallery-dl"; + prependArgs = galleryDlArgs; }; + }; - wrapper-manager.packages.download-media-variants = { - wrappers."yt-dlp-${pathPrefix}" = { - arg0 = lib.getExe' config.services.yt-dlp.package "yt-dlp"; - prependArgs = ytdlpArgs; - }; - - wrappers."gallery-dl-${pathPrefix}" = { - arg0 = lib.getExe' config.services.gallery-dl.package "gallery-dl"; - prependArgs = galleryDlArgs; - }; - }; - - environment.systemPackages = with pkgs; [ archivebox ]; - } - ); + environment.systemPackages = with pkgs; [ archivebox ]; + }); } diff --git a/configs/nixos/ni/modules/services/mail-archive.nix b/configs/nixos/ni/modules/services/mail-archive.nix index 95abc9e2..a5b30adc 100644 --- a/configs/nixos/ni/modules/services/mail-archive.nix +++ b/configs/nixos/ni/modules/services/mail-archive.nix @@ -17,8 +17,7 @@ let newsgroup = "inbox.comp.systemd.devel"; }; }; -in -{ +in { options.hosts.ni.services.mail-archive.enable = lib.mkEnableOption "preferred mail archiving service"; @@ -30,9 +29,7 @@ in http = { enable = true; port = "/run/public-inbox-http.sock"; - mounts = [ - "https://mail.ni.internal/inbox" - ]; + mounts = [ "https://mail.ni.internal/inbox" ]; }; imap.enable = true; nntp.enable = true; @@ -54,7 +51,8 @@ in services.nginx.virtualHosts."mail.ni.internal" = { locations."/".return = "302 /inbox"; locations."= /inbox".return = "302 /inbox/"; - locations."/inbox".proxyPass = "http://unix:${config.services.public-inbox.http.port}:/inbox"; + locations."/inbox".proxyPass = + "http://unix:${config.services.public-inbox.http.port}:/inbox"; locations."= /style/light.css".alias = pkgs.writeText "light.css" '' * { background:#fff; color:#000 } diff --git a/configs/nixos/ni/modules/services/monitoring.nix b/configs/nixos/ni/modules/services/monitoring.nix index 06730711..46d86d63 100644 --- a/configs/nixos/ni/modules/services/monitoring.nix +++ b/configs/nixos/ni/modules/services/monitoring.nix @@ -3,8 +3,7 @@ let hostCfg = config.hosts.ni; cfg = hostCfg.services.monitoring; -in -{ +in { options.hosts.ni.services.monitoring.enable = lib.mkEnableOption "enable local desktop monitoring service"; @@ -13,9 +12,8 @@ in services.grafana.enable = true; - services.grafana.declarativePlugins = with pkgs.grafanaPlugins; [ - grafana-piechart-panel - ]; + services.grafana.declarativePlugins = with pkgs.grafanaPlugins; + [ grafana-piechart-panel ]; services.grafana.settings = { database.type = "sqlite3"; diff --git a/configs/nixos/ni/modules/services/penpot/default.nix b/configs/nixos/ni/modules/services/penpot/default.nix index 7b0bfe4a..efd58740 100644 --- a/configs/nixos/ni/modules/services/penpot/default.nix +++ b/configs/nixos/ni/modules/services/penpot/default.nix @@ -5,15 +5,12 @@ let cfg = hostCfg.services.penpot; port = builtins.toString config.state.ports.penpot-frontend.value; -in -{ +in { options.hosts.ni.services.penpot.enable = lib.mkEnableOption "self-hosted Penpot design tool"; config = lib.mkIf cfg.enable { - state.ports = { - penpot-frontend.value = 9001; - }; + state.ports = { penpot-frontend.value = 9001; }; sops.secrets = foodogsquaredLib.sops-nix.getSecrets ./secrets.yaml { "penpot/env" = { }; @@ -26,17 +23,10 @@ in virtualisation.oci-containers.containers.penpot-frontend = { image = "docker.io/penpotapp/frontend:latest"; - dependsOn = [ - "penpot-backend" - "penpot-exporter" - ]; + dependsOn = [ "penpot-backend" "penpot-exporter" ]; ports = lib.singleton "127.0.0.1:${port}:${port}"; - extraOptions = [ - "--network=penpot" - ]; - volumes = [ - "penpot_assets:/opt/data/assets" - ]; + extraOptions = [ "--network=penpot" ]; + volumes = [ "penpot_assets:/opt/data/assets" ]; environment.PENPOT_FLAGS = lib.concatStringsSep " " [ "enable-login-with-password" "enable-webhooks" @@ -48,19 +38,10 @@ in virtualisation.oci-containers.containers.penpot-backend = { image = "docker.io/penpotapp/backend:latest"; - volumes = [ - "penpot_assets:/opt/data/assets" - ]; - extraOptions = [ - "--network=penpot" - ]; - dependsOn = [ - "penpot-postgres" - "penpot-redis" - ]; - environmentFiles = [ - config.sops.secrets."penpot/env".path - ]; + volumes = [ "penpot_assets:/opt/data/assets" ]; + extraOptions = [ "--network=penpot" ]; + dependsOn = [ "penpot-postgres" "penpot-redis" ]; + environmentFiles = [ config.sops.secrets."penpot/env".path ]; environment = { PENPOT_FLAGS = lib.concatStringsSep " " [ "enable-registration" @@ -77,9 +58,7 @@ in virtualisation.oci-containers.containers.penpot-exporter = { image = "docker.io/penpotapp/exporter:latest"; - extraOptions = [ - "--network=penpot" - ]; + extraOptions = [ "--network=penpot" ]; environment = { PENPOT_PUBLIC_URI = "http://penpot-frontend"; PENPOT_REDIS_URI = "redis://penpot-redis/0"; @@ -88,24 +67,16 @@ in virtualisation.oci-containers.containers.penpot-redis = { image = "docker.io/redis:7"; - extraOptions = [ - "--network=penpot" - ]; + extraOptions = [ "--network=penpot" ]; }; virtualisation.oci-containers.containers.penpot-postgres = { image = "docker.io/postgres:15"; - volumes = [ - "penpot_postgres_v15:/var/lib/postgresql/data" - ]; + volumes = [ "penpot_postgres_v15:/var/lib/postgresql/data" ]; extraOptions = [ "--network=penpot" ]; - environmentFiles = [ - config.sops.secrets."penpot/postgres_env".path - ]; + environmentFiles = [ config.sops.secrets."penpot/postgres_env".path ]; environment = { - POSTGRES_INITDB_ARGS = lib.concatStringsSep " " [ - "--data-checksums" - ]; + POSTGRES_INITDB_ARGS = lib.concatStringsSep " " [ "--data-checksums" ]; POSTGRES_DB = "penpot"; }; }; diff --git a/configs/nixos/ni/modules/services/reverse-proxy.nix b/configs/nixos/ni/modules/services/reverse-proxy.nix index 5b4cb4f1..42db91e5 100644 --- a/configs/nixos/ni/modules/services/reverse-proxy.nix +++ b/configs/nixos/ni/modules/services/reverse-proxy.nix @@ -4,8 +4,7 @@ let hostCfg = config.hosts.ni; cfg = hostCfg.services.reverse-proxy; -in -{ +in { options.hosts.ni.services.reverse-proxy.enable = lib.mkEnableOption "private-use reverse proxy setup"; diff --git a/configs/nixos/ni/modules/services/rss-reader/default.nix b/configs/nixos/ni/modules/services/rss-reader/default.nix index e3d2885d..6e64617c 100644 --- a/configs/nixos/ni/modules/services/rss-reader/default.nix +++ b/configs/nixos/ni/modules/services/rss-reader/default.nix @@ -5,14 +5,13 @@ let cfg = hostCfg.services.rss-reader; port = config.state.ports.miniflux.value; -in -{ +in { options.hosts.ni.services.rss-reader.enable = lib.mkEnableOption "preferred RSS reader service"; config = lib.mkIf cfg.enable { sops.secrets = foodogsquaredLib.sops-nix.getSecrets ./secrets.yaml { - "miniflux/admin" = {}; + "miniflux/admin" = { }; }; state.ports.miniflux.value = 9640; @@ -35,7 +34,8 @@ in wrapper-manager.packages.miniflux-helper = { wrappers.miniflux-helper = { arg0 = lib.getExe' config.services.miniflux.package "miniflux"; - env = lib.mapAttrs (_: value: { value = builtins.toString value; }) config.services.miniflux.config; + env = lib.mapAttrs (_: value: { value = builtins.toString value; }) + config.services.miniflux.config; }; }; }; diff --git a/configs/nixos/ni/modules/setups/desktop.nix b/configs/nixos/ni/modules/setups/desktop.nix index 8d8cd783..15165643 100644 --- a/configs/nixos/ni/modules/setups/desktop.nix +++ b/configs/nixos/ni/modules/setups/desktop.nix @@ -5,9 +5,9 @@ let cfg = hostCfg.setups.desktop; hasAnyWorkflowEnabled = workflows: - lib.lists.any (workflow: lib.elem workflow config.workflows.enable) workflows; -in -{ + lib.lists.any (workflow: lib.elem workflow config.workflows.enable) + workflows; +in { options.hosts.ni.setups.desktop.enable = lib.mkEnableOption "desktop environment setup"; diff --git a/configs/nixos/ni/modules/setups/development.nix b/configs/nixos/ni/modules/setups/development.nix index 83b685d7..a56340f3 100644 --- a/configs/nixos/ni/modules/setups/development.nix +++ b/configs/nixos/ni/modules/setups/development.nix @@ -3,8 +3,7 @@ let hostCfg = config.hosts.ni; cfg = hostCfg.setups.development; -in -{ +in { options.hosts.ni.setups.development.enable = lib.mkEnableOption "software development setup"; @@ -33,15 +32,14 @@ in logDriver = "journald"; }; - environment.systemPackages = with pkgs; - [ - # For debugging build environments in Nix packages. - cntr + environment.systemPackages = with pkgs; [ + # For debugging build environments in Nix packages. + cntr - devpod-desktop + devpod-desktop - freecad - ]; + freecad + ]; # Enable the terminal emulator of choice. programs.wezterm.enable = true; @@ -60,10 +58,7 @@ in }; # Adding a bunch of emulated systems for cross-system building. - boot.binfmt.emulatedSystems = [ - "aarch64-linux" - "riscv64-linux" - ]; + boot.binfmt.emulatedSystems = [ "aarch64-linux" "riscv64-linux" ]; } (lib.mkIf config.suites.dev.containers.enable { @@ -72,9 +67,7 @@ in services.cockpit = { enable = true; port = config.state.ports.cockpit.value; - settings = { - WebService.AllowUnencrypted = true; - }; + settings = { WebService.AllowUnencrypted = true; }; }; # Setting up a single-node k3s cluster for learning purposes. diff --git a/configs/nixos/ni/modules/setups/gaming.nix b/configs/nixos/ni/modules/setups/gaming.nix index 70bb3656..90291969 100644 --- a/configs/nixos/ni/modules/setups/gaming.nix +++ b/configs/nixos/ni/modules/setups/gaming.nix @@ -3,10 +3,8 @@ let hostCfg = config.hosts.ni; cfg = hostCfg.setups.gaming; -in -{ - options.hosts.ni.setups.gaming.enable = - lib.mkEnableOption "gaming setup"; +in { + options.hosts.ni.setups.gaming.enable = lib.mkEnableOption "gaming setup"; config = lib.mkIf cfg.enable { # Bring all of the goodies. @@ -16,12 +14,7 @@ in retro-computing.enable = true; }; - programs.retroarch.cores = with pkgs.libretro; [ - pcsx2 - dolphin - citra - mame - ]; + programs.retroarch.cores = with pkgs.libretro; [ pcsx2 dolphin citra mame ]; # Bring more of them games. environment.systemPackages = with pkgs; [ diff --git a/configs/nixos/ni/modules/setups/music.nix b/configs/nixos/ni/modules/setups/music.nix index 4badd22a..839bdf17 100644 --- a/configs/nixos/ni/modules/setups/music.nix +++ b/configs/nixos/ni/modules/setups/music.nix @@ -3,8 +3,7 @@ let hostCfg = config.hosts.ni; cfg = hostCfg.setups.music; -in -{ +in { options.hosts.ni.setups.music.enable = lib.mkEnableOption "music streaming and organizing setup"; @@ -29,7 +28,8 @@ in }; uxplay = { value = 10001; - openFirewall = true; }; + openFirewall = true; + }; uxplayClients = { value = foodogsquaredLib.nixos.makeRange' uxplay.value 10; openFirewall = true; @@ -40,12 +40,10 @@ in services.gonic = { enable = true; settings = rec { - listen-addr = "localhost:${builtins.toString config.state.ports.gonic.value}"; + listen-addr = + "localhost:${builtins.toString config.state.ports.gonic.value}"; cache-path = "${config.state.paths.cacheDir}/gonic"; - music-path = - [ - "/srv/Music" - ]; + music-path = [ "/srv/Music" ]; podcast-path = "${cache-path}/podcasts"; playlists-path = "${cache-path}/playlists"; @@ -102,9 +100,7 @@ in airplay = { type = "airplay"; location = lib.getExe' pkgs.shairport-sync "shairport-sync"; - query = { - devicename = "Snapcast"; - }; + query = { devicename = "Snapcast"; }; }; spotify = { diff --git a/configs/nixos/plover/default.nix b/configs/nixos/plover/default.nix index d570f413..e29a1e36 100644 --- a/configs/nixos/plover/default.nix +++ b/configs/nixos/plover/default.nix @@ -39,7 +39,8 @@ }; # Overriding the kernel version for ourselves. - boot.kernelPackages = lib.mkOverride 500 pkgs.linuxKernel.packages.linux_6_11_hardened; + boot.kernelPackages = + lib.mkOverride 500 pkgs.linuxKernel.packages.linux_6_11_hardened; # We're using our own VPN configuration for this one. suites.vpn.personal.enable = true; diff --git a/configs/nixos/plover/files/gitea/versions.tf b/configs/nixos/plover/files/gitea/versions.tf index a5629f10..d4d2cc24 100644 --- a/configs/nixos/plover/files/gitea/versions.tf +++ b/configs/nixos/plover/files/gitea/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { gitea = { - source = "go-gitea/gitea" + source = "go-gitea/gitea" version = "0.5.1" } } diff --git a/configs/nixos/plover/modules/hardware/networks.nix b/configs/nixos/plover/modules/hardware/networks.nix index 1b7b9dbb..de310d79 100644 --- a/configs/nixos/plover/modules/hardware/networks.nix +++ b/configs/nixos/plover/modules/hardware/networks.nix @@ -1,10 +1,8 @@ # It just contains a set of network-related variables mainly used for # network-related services. Make sure to change this every time you migrate to # a new server. -let - inherit (builtins) toString; -in -rec { +let inherit (builtins) toString; +in rec { # This is expected to be /48 block (i.e., `fc00:b0de:5685::/48`). # The thing is generated using a ULA generator. privateIPv6Prefix = "fd89:c181:8016"; diff --git a/configs/nixos/plover/modules/profiles/hetzner-cloud-cx22.nix b/configs/nixos/plover/modules/profiles/hetzner-cloud-cx22.nix index c96eb7fa..c378cf0a 100644 --- a/configs/nixos/plover/modules/profiles/hetzner-cloud-cx22.nix +++ b/configs/nixos/plover/modules/profiles/hetzner-cloud-cx22.nix @@ -1,9 +1,7 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = [ - (modulesPath + "/profiles/qemu-guest.nix") - ]; + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; # Hetzner can only support non-UEFI bootloader (or at least it doesn't with # systemd-boot). @@ -13,12 +11,14 @@ efiInstallAsRemovable = true; }; - boot.initrd.availableKernelModules = [ "ata_piix" "virtio_pci" "virtio_scsi" "xhci_pci" "sd_mod" "sr_mod" ]; + boot.initrd.availableKernelModules = + [ "ata_piix" "virtio_pci" "virtio_scsi" "xhci_pci" "sd_mod" "sr_mod" ]; boot.initrd.kernelModules = [ "nvme" ]; zramSwap.enable = true; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; services.qemuGuest.enable = true; systemd.services.qemu-guest-agent.path = [ pkgs.shadow ]; diff --git a/configs/nixos/plover/modules/services/atuin.nix b/configs/nixos/plover/modules/services/atuin.nix index e4d4fbd5..6040655b 100644 --- a/configs/nixos/plover/modules/services/atuin.nix +++ b/configs/nixos/plover/modules/services/atuin.nix @@ -11,8 +11,7 @@ let atuinInternalDomain = "atuin.${config.networking.fqdn}"; host = interfaces.lan.IPv4.address; -in -{ +in { options.hosts.plover.services.atuin.enable = lib.mkEnableOption "Atuin sync server setup"; diff --git a/configs/nixos/plover/modules/services/backup.nix b/configs/nixos/plover/modules/services/backup.nix index 2b5b5e88..d30d77f1 100644 --- a/configs/nixos/plover/modules/services/backup.nix +++ b/configs/nixos/plover/modules/services/backup.nix @@ -7,63 +7,64 @@ let # The head of the Borgbase hostname. hetzner-boxes-user = "u332477"; hetzner-boxes-server = "${hetzner-boxes-user}.your-storagebox.de"; - borgRepo = path: "ssh://${hetzner-boxes-user}@${hetzner-boxes-server}:23/./borg/plover/${path}"; + borgRepo = path: + "ssh://${hetzner-boxes-user}@${hetzner-boxes-server}:23/./borg/plover/${path}"; - jobCommonSettings = { patternFiles ? [ ], patterns ? [ ], paths ? [ ], repo, passCommand }: { - inherit paths repo; - compression = "zstd,11"; - dateFormat = "+%F-%H-%M-%S-%z"; - doInit = true; - encryption = { - inherit passCommand; - mode = "repokey-blake2"; - }; - extraCreateArgs = - let + jobCommonSettings = + { patternFiles ? [ ], patterns ? [ ], paths ? [ ], repo, passCommand }: { + inherit paths repo; + compression = "zstd,11"; + dateFormat = "+%F-%H-%M-%S-%z"; + doInit = true; + encryption = { + inherit passCommand; + mode = "repokey-blake2"; + }; + extraCreateArgs = let args = lib.flatten [ (builtins.map (patternFile: "--patterns-from ${lib.escapeShellArg patternFile}") patternFiles) - (builtins.map - (pattern: "--pattern ${lib.escapeShellArg pattern}") + (builtins.map (pattern: "--pattern ${lib.escapeShellArg pattern}") patterns) ]; - in - lib.concatStringsSep " " args; - extraInitArgs = "--make-parent-dirs"; - persistentTimer = true; - preHook = '' - extraCreateArgs="$extraCreateArgs --stats" - ''; - prune.keep = { - weekly = 4; - monthly = 12; - yearly = 6; + in lib.concatStringsSep " " args; + extraInitArgs = "--make-parent-dirs"; + persistentTimer = true; + preHook = '' + extraCreateArgs="$extraCreateArgs --stats" + ''; + prune.keep = { + weekly = 4; + monthly = 12; + yearly = 6; + }; + startAt = "monthly"; + environment.BORG_RSH = "ssh -i ${config.sops.secrets."ssh-key".path}"; }; - startAt = "monthly"; - environment.BORG_RSH = "ssh -i ${config.sops.secrets."ssh-key".path}"; - }; -in -{ +in { options.hosts.plover.services.backup.enable = lib.mkEnableOption "backup service"; config = lib.mkIf cfg.enable { - sops.secrets = foodogsquaredLib.sops-nix.getSecrets ../../secrets/secrets.yaml { - "borg/repos/services/password" = { }; - }; + sops.secrets = + foodogsquaredLib.sops-nix.getSecrets ../../secrets/secrets.yaml { + "borg/repos/services/password" = { }; + }; services.borgbackup.jobs = { # Backups for various services. - services-backup = jobCommonSettings - { - paths = [ - # ACME accounts and TLS certificates - "/var/lib/acme" - ]; - repo = borgRepo "services"; - passCommand = "cat ${config.sops.secrets."borg/repos/services/password".path}"; - } // { startAt = "daily"; }; + services-backup = jobCommonSettings { + paths = [ + # ACME accounts and TLS certificates + "/var/lib/acme" + ]; + repo = borgRepo "services"; + passCommand = + "cat ${config.sops.secrets."borg/repos/services/password".path}"; + } // { + startAt = "daily"; + }; }; programs.ssh.extraConfig = '' diff --git a/configs/nixos/plover/modules/services/crowdsec.nix b/configs/nixos/plover/modules/services/crowdsec.nix index 0d34376f..9483031f 100644 --- a/configs/nixos/plover/modules/services/crowdsec.nix +++ b/configs/nixos/plover/modules/services/crowdsec.nix @@ -3,8 +3,7 @@ let hostCfg = config.hosts.plover; cfg = hostCfg.services.crowdsec; -in -{ +in { options.hosts.plover.services.crowdsec.enable = lib.mkEnableOption "Crowdsec service"; diff --git a/configs/nixos/plover/modules/services/database.nix b/configs/nixos/plover/modules/services/database.nix index 000c1149..b7a31b1a 100644 --- a/configs/nixos/plover/modules/services/database.nix +++ b/configs/nixos/plover/modules/services/database.nix @@ -7,8 +7,7 @@ let cfg = hostCfg.services.database; postgresqlDomain = "postgres.${config.networking.domain}"; -in -{ +in { options.hosts.plover.services.database.enable = lib.mkEnableOption "preferred service SQL database"; @@ -22,10 +21,8 @@ in enableTCPIP = true; settings = - let - credsDir = path: "/run/credentials/postgresql.service/${path}"; - in - { + let credsDir = path: "/run/credentials/postgresql.service/${path}"; + in { port = config.state.ports.postgresql.value; # Still doing the secure schema usage pattern. @@ -50,16 +47,15 @@ in # Setting this up for TLS. systemd.services.postgresql = { requires = [ "acme-finished-${postgresqlDomain}.target" ]; - serviceConfig.LoadCredential = - let - certDirectory = config.security.acme.certs."${postgresqlDomain}".directory; - certCredentialPath = path: "${path}:${certDirectory}/${path}"; - in - [ - (certCredentialPath "cert.pem") - (certCredentialPath "key.pem") - (certCredentialPath "fullchain.pem") - ]; + serviceConfig.LoadCredential = let + certDirectory = + config.security.acme.certs."${postgresqlDomain}".directory; + certCredentialPath = path: "${path}:${certDirectory}/${path}"; + in [ + (certCredentialPath "cert.pem") + (certCredentialPath "key.pem") + (certCredentialPath "fullchain.pem") + ]; }; security.acme.certs."${postgresqlDomain}".postRun = '' @@ -69,7 +65,8 @@ in (lib.mkIf hostCfg.services.backup.enable { # Add the dumps to be backed up. - services.borgbackup.jobs.services-backup.paths = [ config.services.postgresqlBackup.location ]; + services.borgbackup.jobs.services-backup.paths = + [ config.services.postgresqlBackup.location ]; }) ]); } diff --git a/configs/nixos/plover/modules/services/dns-server/default.nix b/configs/nixos/plover/modules/services/dns-server/default.nix index b70e0732..480a961f 100644 --- a/configs/nixos/plover/modules/services/dns-server/default.nix +++ b/configs/nixos/plover/modules/services/dns-server/default.nix @@ -26,8 +26,7 @@ let }; dnsSubdomain = "ns1.${domain}"; -in -{ +in { options.hosts.plover.services.dns-server.enable = lib.mkEnableOption "preferred DNS server"; @@ -39,19 +38,17 @@ in dnsOverTLS.value = 853; }; - sops.secrets = - let - dnsFileAttribute = { - owner = config.users.users.named.name; - group = config.users.users.named.group; - mode = "0400"; - }; - in - foodogsquaredLib.sops-nix.getSecrets ./secrets.yaml { - "dns/${domain}/rfc2136-key" = dnsFileAttribute // { - reloadUnits = [ "bind.service" ]; - }; + sops.secrets = let + dnsFileAttribute = { + owner = config.users.users.named.name; + group = config.users.users.named.group; + mode = "0400"; }; + in foodogsquaredLib.sops-nix.getSecrets ./secrets.yaml { + "dns/${domain}/rfc2136-key" = dnsFileAttribute // { + reloadUnits = [ "bind.service" ]; + }; + }; # Install the utilities. environment.systemPackages = [ config.services.bind.package ]; @@ -60,137 +57,141 @@ in enable = true; forward = "first"; - cacheNetworks = [ - "127.0.0.1" - "::1" - ]; + cacheNetworks = [ "127.0.0.1" "::1" ]; - listenOn = [ - "127.0.0.1" - wan.ipv4 - lan.ipv4 - ]; + listenOn = [ "127.0.0.1" wan.ipv4 lan.ipv4 ]; - listenOnIpv6 = [ - "::1" - wan.ipv6 - lan.ipv6 - ]; + listenOnIpv6 = [ "::1" wan.ipv6 lan.ipv6 ]; # Welp, since the template is pretty limited, we'll have to go with our # own. This is partially based from the NixOS Bind module except without # the template for filling in zones since we use views. - configFile = - let - cfg = config.services.bind; - certDir = path: "/run/credentials/bind.service/${path}"; - listenInterfaces = lib.concatMapStrings (entry: " ${entry}; ") cfg.listenOn; - listenInterfacesIpv6 = lib.concatMapStrings (entry: " ${entry}; ") cfg.listenOnIpv6; - in - pkgs.writeText "named.conf" '' - include "/etc/bind/rndc.key"; - include "${config.sops.secrets."dns/${domain}/rfc2136-key".path}"; + configFile = let + cfg = config.services.bind; + certDir = path: "/run/credentials/bind.service/${path}"; + listenInterfaces = + lib.concatMapStrings (entry: " ${entry}; ") cfg.listenOn; + listenInterfacesIpv6 = + lib.concatMapStrings (entry: " ${entry}; ") cfg.listenOnIpv6; + in pkgs.writeText "named.conf" '' + include "/etc/bind/rndc.key"; + include "${config.sops.secrets."dns/${domain}/rfc2136-key".path}"; - controls { - inet 127.0.0.1 allow {localhost;} keys {"rndc-key";}; + controls { + inet 127.0.0.1 allow {localhost;} keys {"rndc-key";}; + }; + + tls ${dnsSubdomain} { + key-file "${certDir "key.pem"}"; + cert-file "${certDir "cert.pem"}"; + dhparam-file "${config.security.dhparams.params.bind.path}"; + ciphers "HIGH:!kRSA:!aNULL:!eNULL:!RC4:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!SHA1:!SHA256:!SHA384"; + prefer-server-ciphers yes; + session-tickets no; + }; + + http ${dnsSubdomain} { + endpoints { "/dns-query"; }; + }; + + acl trusted { ${ + lib.concatStringsSep "; " [ "10.0.0.0/8" ] + }; localhost; }; + acl cachenetworks { ${ + lib.concatMapStrings (entry: " ${entry}; ") cfg.cacheNetworks + } }; + acl badnetworks { ${ + lib.concatMapStrings (entry: " ${entry}; ") cfg.blockedNetworks + } }; + + options { + # Native DNS. + listen-on { ${listenInterfaces} }; + listen-on-v6 { ${listenInterfacesIpv6} }; + + # DNS-over-TLS. + listen-on tls ${dnsSubdomain} { ${listenInterfaces} }; + listen-on-v6 tls ${dnsSubdomain} { ${listenInterfacesIpv6} }; + + # DNS-over-HTTPS. + tls-port ${builtins.toString config.state.ports.dnsOverTLS.value}; + https-port ${ + builtins.toString config.state.ports.dnsOverHTTPS.value + }; + listen-on tls ${dnsSubdomain} http ${dnsSubdomain} { ${listenInterfaces} }; + listen-on-v6 tls ${dnsSubdomain} http ${dnsSubdomain} { ${listenInterfacesIpv6} }; + + allow-query { cachenetworks; }; + blackhole { badnetworks; }; + forward ${cfg.forward}; + forwarders { ${ + lib.concatMapStrings (entry: " ${entry}; ") cfg.forwarders + } }; + directory "${cfg.directory}"; + pid-file "/run/named/named.pid"; + }; + + view internal { + match-clients { trusted; }; + + allow-query { any; }; + allow-recursion { any; }; + + // We'll use systemd-resolved as our forwarder. + forwarders { 127.0.0.53 port 53; }; + + zone "${fqdn}" { + type primary; + file "${getZoneFile fqdn}"; }; - tls ${dnsSubdomain} { - key-file "${certDir "key.pem"}"; - cert-file "${certDir "cert.pem"}"; - dhparam-file "${config.security.dhparams.params.bind.path}"; - ciphers "HIGH:!kRSA:!aNULL:!eNULL:!RC4:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!SHA1:!SHA256:!SHA384"; - prefer-server-ciphers yes; - session-tickets no; - }; + zone "${domain}" { + type primary; - http ${dnsSubdomain} { - endpoints { "/dns-query"; }; - }; - - acl trusted { ${lib.concatStringsSep "; " [ "10.0.0.0/8" ]}; localhost; }; - acl cachenetworks { ${lib.concatMapStrings (entry: " ${entry}; ") cfg.cacheNetworks} }; - acl badnetworks { ${lib.concatMapStrings (entry: " ${entry}; ") cfg.blockedNetworks} }; - - options { - # Native DNS. - listen-on { ${listenInterfaces} }; - listen-on-v6 { ${listenInterfacesIpv6} }; - - # DNS-over-TLS. - listen-on tls ${dnsSubdomain} { ${listenInterfaces} }; - listen-on-v6 tls ${dnsSubdomain} { ${listenInterfacesIpv6} }; - - # DNS-over-HTTPS. - tls-port ${builtins.toString config.state.ports.dnsOverTLS.value}; - https-port ${builtins.toString config.state.ports.dnsOverHTTPS.value}; - listen-on tls ${dnsSubdomain} http ${dnsSubdomain} { ${listenInterfaces} }; - listen-on-v6 tls ${dnsSubdomain} http ${dnsSubdomain} { ${listenInterfacesIpv6} }; - - allow-query { cachenetworks; }; - blackhole { badnetworks; }; - forward ${cfg.forward}; - forwarders { ${lib.concatMapStrings (entry: " ${entry}; ") cfg.forwarders} }; - directory "${cfg.directory}"; - pid-file "/run/named/named.pid"; - }; - - view internal { - match-clients { trusted; }; - - allow-query { any; }; - allow-recursion { any; }; - - // We'll use systemd-resolved as our forwarder. - forwarders { 127.0.0.53 port 53; }; - - zone "${fqdn}" { - type primary; - file "${getZoneFile fqdn}"; - }; - - zone "${domain}" { - type primary; - - file "${getZoneFile domain}"; - allow-transfer { ${lib.concatStringsSep "; " config.state.network.secondaryNameservers}; }; - update-policy { - grant rfc2136key.${domain}. zonesub TXT; - }; + file "${getZoneFile domain}"; + allow-transfer { ${ + lib.concatStringsSep "; " + config.state.network.secondaryNameservers + }; }; + update-policy { + grant rfc2136key.${domain}. zonesub TXT; }; }; + }; - view external { - match-clients { any; }; + view external { + match-clients { any; }; - forwarders { }; - empty-zones-enable yes; - allow-query { any; }; - allow-recursion { none; }; + forwarders { }; + empty-zones-enable yes; + allow-query { any; }; + allow-recursion { none; }; - zone "${domain}" { - in-view internal; - }; + zone "${domain}" { + in-view internal; }; + }; - ${cfg.extraConfig} - ''; + ${cfg.extraConfig} + ''; }; systemd.services.bind = { path = with pkgs; [ replace-secret ]; - preStart = - let - domainZone' = getZoneFile domain; - fqdnZone' = getZoneFile fqdn; - in - lib.mkAfter '' - # Install the domain zone. - [ -f ${lib.escapeShellArg domainZone'} ] || install -Dm0600 ${zonefile} ${lib.escapeShellArg domainZone'} + preStart = let + domainZone' = getZoneFile domain; + fqdnZone' = getZoneFile fqdn; + in lib.mkAfter '' + # Install the domain zone. + [ -f ${ + lib.escapeShellArg domainZone' + } ] || install -Dm0600 ${zonefile} ${lib.escapeShellArg domainZone'} - # Install the internal DNS zones. - [ -f ${lib.escapeShellArg fqdnZone'} ] || install -Dm0600 '${fqdnZone}' ${lib.escapeShellArg fqdnZone'} - ''; + # Install the internal DNS zones. + [ -f ${ + lib.escapeShellArg fqdnZone' + } ] || install -Dm0600 '${fqdnZone}' ${lib.escapeShellArg fqdnZone'} + ''; serviceConfig = { # Additional service hardening. You can see most of the options from @@ -200,16 +201,15 @@ in UMask = "0037"; # Get the credentials into the service. - LoadCredential = - let - certDirectory = config.security.acme.certs."${dnsSubdomain}".directory; - certCredentialPath = path: "${path}:${certDirectory}/${path}"; - in - [ - (certCredentialPath "cert.pem") - (certCredentialPath "key.pem") - (certCredentialPath "fullchain.pem") - ]; + LoadCredential = let + certDirectory = + config.security.acme.certs."${dnsSubdomain}".directory; + certCredentialPath = path: "${path}:${certDirectory}/${path}"; + in [ + (certCredentialPath "cert.pem") + (certCredentialPath "key.pem") + (certCredentialPath "fullchain.pem") + ]; LogFilterPatterns = [ # systemd-resolved doesn't have DNS cookie support, it seems. @@ -232,10 +232,7 @@ in # Make the filesystem invisible to the service. ProtectSystem = "strict"; - ReadWritePaths = [ - config.services.bind.directory - "/etc/bind" - ]; + ReadWritePaths = [ config.services.bind.directory "/etc/bind" ]; ReadOnlyPaths = [ config.security.dhparams.params.bind.path config.security.acme.certs."${dnsSubdomain}".directory @@ -262,13 +259,8 @@ in AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ]; # Restrict what address families can it access. - RestrictAddressFamilies = [ - "AF_LOCAL" - "AF_NETLINK" - "AF_BRIDGE" - "AF_INET" - "AF_INET6" - ]; + RestrictAddressFamilies = + [ "AF_LOCAL" "AF_NETLINK" "AF_BRIDGE" "AF_INET" "AF_INET6" ]; # Restricting what namespaces it can create. RestrictNamespaces = true; @@ -284,14 +276,18 @@ in services.bind.extraConfig = '' statistics-channels { - inet 127.0.0.1 port ${builtins.toString config.state.ports.bindStatistics.value} allow { 127.0.0.1; }; + inet 127.0.0.1 port ${ + builtins.toString config.state.ports.bindStatistics.value + } allow { 127.0.0.1; }; }; ''; services.prometheus.exporters = { bind = { enable = true; - bindURI = "http://127.0.0.1/${builtins.toString config.state.ports.bindStatistics.value}"; + bindURI = "http://127.0.0.1/${ + builtins.toString config.state.ports.bindStatistics.value + }"; }; }; }) @@ -303,7 +299,9 @@ in zone dns 64k; ''; servers = { - "127.0.0.1:${builtins.toString config.state.ports.dnsOverHTTPS.value}" = { }; + "127.0.0.1:${ + builtins.toString config.state.ports.dnsOverHTTPS.value + }" = { }; }; }; diff --git a/configs/nixos/plover/modules/services/fail2ban.nix b/configs/nixos/plover/modules/services/fail2ban.nix index 4cb3ac00..55cbc7f1 100644 --- a/configs/nixos/plover/modules/services/fail2ban.nix +++ b/configs/nixos/plover/modules/services/fail2ban.nix @@ -5,8 +5,7 @@ let cfg = hostCfg.services.fail2ban; inherit (import ../hardware/networks.nix) interfaces; -in -{ +in { options.hosts.plover.services.fail2ban.enable = lib.mkEnableOption "fail2ban monitoring"; diff --git a/configs/nixos/plover/modules/services/firewall.nix b/configs/nixos/plover/modules/services/firewall.nix index ce276b6f..8f3cfc10 100644 --- a/configs/nixos/plover/modules/services/firewall.nix +++ b/configs/nixos/plover/modules/services/firewall.nix @@ -3,9 +3,9 @@ let hostCfg = config.hosts.plover; cfg = hostCfg.services.firewall; -in -{ - options.hosts.plover.services.firewall.enable = lib.mkEnableOption "firewall setup"; +in { + options.hosts.plover.services.firewall.enable = + lib.mkEnableOption "firewall setup"; config = lib.mkIf cfg.enable { networking = { diff --git a/configs/nixos/plover/modules/services/idm.nix b/configs/nixos/plover/modules/services/idm.nix index c641c207..0a411820 100644 --- a/configs/nixos/plover/modules/services/idm.nix +++ b/configs/nixos/plover/modules/services/idm.nix @@ -10,9 +10,9 @@ let certsDir = config.security.acme.certs."${authDomain}".directory; backupsDir = "${config.state.paths.dataDir}/kanidm/backups"; -in -{ - options.hosts.plover.services.idm.enable = lib.mkEnableOption "preferred IDM server"; +in { + options.hosts.plover.services.idm.enable = + lib.mkEnableOption "preferred IDM server"; config = lib.mkIf cfg.enable (lib.mkMerge [ { @@ -61,7 +61,10 @@ in # Integrating kanidm-unixd. UsePAM = true; PubkeyAuthentication = true; - AuthorizedKeysCommand = "${lib.getExe' config.services.kanidm.package "kanidm_ssh_authorizedkeys"} %u"; + AuthorizedKeysCommand = "${ + lib.getExe' config.services.kanidm.package + "kanidm_ssh_authorizedkeys" + } %u"; AuthorizedKeysCommandUser = "nobody"; }; @@ -73,7 +76,8 @@ in mkdir -p "${backupsDir}" ''; serviceConfig = { - SupplementaryGroups = [ config.security.acme.certs."${authDomain}".group ]; + SupplementaryGroups = + [ config.security.acme.certs."${authDomain}".group ]; }; }; } @@ -91,9 +95,7 @@ in extraConfig = '' zone services; ''; - servers = { - "localhost:${builtins.toString port}" = { }; - }; + servers = { "localhost:${builtins.toString port}" = { }; }; }; }) diff --git a/configs/nixos/plover/modules/services/monitoring.nix b/configs/nixos/plover/modules/services/monitoring.nix index 9e6e2a61..e9312427 100644 --- a/configs/nixos/plover/modules/services/monitoring.nix +++ b/configs/nixos/plover/modules/services/monitoring.nix @@ -5,32 +5,28 @@ let cfg = hostCfg.services.monitoring; prometheusExports = config.services.prometheus.exporters; -in -{ +in { options.hosts.plover.services.monitoring.enable = lib.mkEnableOption "preferred monitoring stack"; - config = lib.mkIf cfg.enable (lib.mkMerge [ - { - services.prometheus = { - enable = true; + config = lib.mkIf cfg.enable (lib.mkMerge [{ + services.prometheus = { + enable = true; - exporters = { - node = { - enable = true; - enabledCollectors = [ "systemd" ]; - }; + exporters = { + node = { + enable = true; + enabledCollectors = [ "systemd" ]; }; - - scrapeConfigs = [ - { - job_name = config.networking.hostName; - static_configs = [{ - targets = [ "127.0.0.1:${builtins.toString prometheusExports.node.port}" ]; - }]; - } - ]; }; - } - ]); + + scrapeConfigs = [{ + job_name = config.networking.hostName; + static_configs = [{ + targets = + [ "127.0.0.1:${builtins.toString prometheusExports.node.port}" ]; + }]; + }]; + }; + }]); } diff --git a/configs/nixos/plover/modules/services/networking.nix b/configs/nixos/plover/modules/services/networking.nix index cceb0504..e516d465 100644 --- a/configs/nixos/plover/modules/services/networking.nix +++ b/configs/nixos/plover/modules/services/networking.nix @@ -8,8 +8,7 @@ let mainEthernetInterfaceNames = [ "eth0" "enp1s0" ]; internalEthernetInterfaceNames = [ "enp7s0" ]; inherit (config.state.network) interfaces; -in -{ +in { options.hosts.plover.services.networking = { enable = lib.mkEnableOption "preferred networking setup"; @@ -67,8 +66,7 @@ in # For more information, you can look at Hetzner documentation from # https://docs.hetzner.com/robot/dedicated-server/ip/additional-ip-adresses/ networks = { - "10-wan" = let - inherit (interfaces) wan; + "10-wan" = let inherit (interfaces) wan; in { matchConfig = { Name = lib.concatStringsSep " " mainEthernetInterfaceNames; @@ -87,10 +85,7 @@ in }; address = [ "${wan.ipv6}/64" ]; - dns = [ - "2a01:4ff:ff00::add:2" - "2a01:4ff:ff00::add:1" - ]; + dns = [ "2a01:4ff:ff00::add:2" "2a01:4ff:ff00::add:1" ]; routes = [ { @@ -102,28 +97,27 @@ in Gateway = wan.ipv6Gateway; GatewayOnLink = true; } - ] - ++ lib.optionals cfg.restrictLocalOnWAN [ - { - Destination = "176.16.0.0/12"; - Type = "unreachable"; - } + ] ++ lib.optionals cfg.restrictLocalOnWAN [ + { + Destination = "176.16.0.0/12"; + Type = "unreachable"; + } - { - Destination = "10.0.0.0/8"; - Type = "unreachable"; - } + { + Destination = "10.0.0.0/8"; + Type = "unreachable"; + } - { - Destination = "192.168.0.0/16"; - Type = "unreachable"; - } + { + Destination = "192.168.0.0/16"; + Type = "unreachable"; + } - { - Destination = "fc00::/7"; - Type = "unreachable"; - } - ]; + { + Destination = "fc00::/7"; + Type = "unreachable"; + } + ]; linkConfig.RequiredForOnline = "routable"; }; diff --git a/configs/nixos/plover/modules/services/wezterm-mux-server.nix b/configs/nixos/plover/modules/services/wezterm-mux-server.nix index 159c2834..bc5695c9 100644 --- a/configs/nixos/plover/modules/services/wezterm-mux-server.nix +++ b/configs/nixos/plover/modules/services/wezterm-mux-server.nix @@ -13,8 +13,7 @@ let src = ../../config/wezterm/config.lua; listen_address = listenAddress; }; -in -{ +in { options.hosts.plover.services.wezterm-mux-server.enable = lib.mkEnableOption "Wezterm mux server setup"; @@ -29,16 +28,14 @@ in requires = [ "acme-finished-${weztermDomain}.target" ]; environment.WEZTERM_LOG = "info"; serviceConfig = { - LoadCredential = - let - certDir = config.security.acme.certs."${weztermDomain}".directory; - credentialCertPath = path: "${path}:${certDir}/${path}"; - in - [ - (credentialCertPath "key.pem") - (credentialCertPath "cert.pem") - (credentialCertPath "fullchain.pem") - ]; + LoadCredential = let + certDir = config.security.acme.certs."${weztermDomain}".directory; + credentialCertPath = path: "${path}:${certDir}/${path}"; + in [ + (credentialCertPath "key.pem") + (credentialCertPath "cert.pem") + (credentialCertPath "fullchain.pem") + ]; }; }; diff --git a/configs/nixos/plover/terraform/dns.tf b/configs/nixos/plover/terraform/dns.tf index 6c776748..ff10ece8 100644 --- a/configs/nixos/plover/terraform/dns.tf +++ b/configs/nixos/plover/terraform/dns.tf @@ -1,30 +1,30 @@ -variable zone_id { +variable "zone_id" { description = "Hetzner DNS zone ID to be configured with." } resource "hetznerdns_record" "plover_ipv4" { zone_id = var.zone_id - name = "plover" - type = "A" - value = hcloud_server.plover.ipv4_address + name = "plover" + type = "A" + value = hcloud_server.plover.ipv4_address } resource "hetznerdns_record" "plover_ipv6" { zone_id = var.zone_id - name = "plover" - type = "AAAA" - value = hcloud_server.plover.ipv6_address + name = "plover" + type = "AAAA" + value = hcloud_server.plover.ipv6_address } -variable services { - type = list(string) - default = [ "auth", "pass", "code" ] +variable "services" { + type = list(string) + default = ["auth", "pass", "code"] } resource "hetznerdns_record" "plover_services" { for_each = toset(var.services) - zone_id = var.zone_id - name = each.key - type = "CNAME" - value = "plover" + zone_id = var.zone_id + name = each.key + type = "CNAME" + value = "plover" } diff --git a/configs/nixos/plover/terraform/main.tf b/configs/nixos/plover/terraform/main.tf index e410f94b..6fa77ae1 100644 --- a/configs/nixos/plover/terraform/main.tf +++ b/configs/nixos/plover/terraform/main.tf @@ -1,5 +1,5 @@ variable "ssh_keys" { - type = list(number) + type = list(number) description = "SSH keys for the associated server" } @@ -23,7 +23,7 @@ resource "hcloud_server" "plover" { } resource "hcloud_ssh_key" "plover" { - name = "plover.foodogsquared.one" + name = "plover.foodogsquared.one" public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGo3tfNQjWZ5pxlqREfBgQJxdNzGHKJIy5hDS9Z+Hpth plover.foodogsquared.one" } diff --git a/configs/nixos/plover/terraform/tailscale.tf b/configs/nixos/plover/terraform/tailscale.tf index 117d766b..9ebd0bf5 100644 --- a/configs/nixos/plover/terraform/tailscale.tf +++ b/configs/nixos/plover/terraform/tailscale.tf @@ -3,25 +3,25 @@ data "tailscale_device" "plover" { } resource "tailscale_device_authorization" "plover_authorization" { - device_id = data.tailscale_device.plover.id + device_id = data.tailscale_device.plover.id authorized = true - depends_on = [ hcloud_server.plover ] + depends_on = [hcloud_server.plover] } resource "tailscale_tailnet_key" "plover" { - reusable = false - ephemeral = false - preauthorized = true + reusable = false + ephemeral = false + preauthorized = true recreate_if_invalid = "always" - description = "Plover" + description = "Plover" } resource "tailscale_device_tags" "hcloud_plover" { device_id = data.tailscale_device.plover.id - tags = [ "tag:server" ] + tags = ["tag:server"] } resource "local_file" "tailscale_auth_key" { - content = tailscale_tailnet_key.plover.key + content = tailscale_tailnet_key.plover.key filename = "${path.module}/plover-tailscale-auth-key" } diff --git a/configs/nixos/plover/terraform/versions.tf b/configs/nixos/plover/terraform/versions.tf index 30a92369..c8ab8927 100644 --- a/configs/nixos/plover/terraform/versions.tf +++ b/configs/nixos/plover/terraform/versions.tf @@ -6,17 +6,17 @@ terraform { } hetznerdns = { - source = "timohirt/hetznerdns" + source = "timohirt/hetznerdns" version = "2.2.0" } tailscale = { - source = "tailscale/tailscale" + source = "tailscale/tailscale" version = "0.17.2" } local = { - source = "hashicorp/local" + source = "hashicorp/local" version = "2.5.2" } } diff --git a/configs/nixos/winnowing/default.nix b/configs/nixos/winnowing/default.nix index 55f6417a..f502e044 100644 --- a/configs/nixos/winnowing/default.nix +++ b/configs/nixos/winnowing/default.nix @@ -5,11 +5,7 @@ "${modulesPath}/profiles/minimal.nix" (foodogsquaredLib.mapHomeManagerUser "winnow" { - extraGroups = [ - "wheel" - "docker" - "podman" - ]; + extraGroups = [ "wheel" "docker" "podman" ]; hashedPassword = "$y$j9T$UFzEKZZZrmbJ05CTY8QAW0$X2RD4m.xswyJlXZC6AlmmuubPaWPQZg/Q1LDgHpXHx1"; isNormalUser = true; diff --git a/configs/nixvim/fiesta/modules/setups/completion.nix b/configs/nixvim/fiesta/modules/setups/completion.nix index ba59595c..845de33c 100644 --- a/configs/nixvim/fiesta/modules/setups/completion.nix +++ b/configs/nixvim/fiesta/modules/setups/completion.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.fiesta; cfg = nixvimCfg.setups.completion; -in -{ +in { options.nixvimConfigs.fiesta.setups.completion.enable = lib.mkEnableOption "debugging setup for Fiesta NixVim"; @@ -26,11 +25,8 @@ in "" = "cmp.mapping.select_prev_item()"; }; - settings.sources = [ - { name = "nvim_lsp"; } - { name = "path"; } - { name = "buffer"; } - ]; + settings.sources = + [ { name = "nvim_lsp"; } { name = "path"; } { name = "buffer"; } ]; }; # All of the typical completion sources I would need. diff --git a/configs/nixvim/fiesta/modules/setups/debugging.nix b/configs/nixvim/fiesta/modules/setups/debugging.nix index 1356fb42..2d45939a 100644 --- a/configs/nixvim/fiesta/modules/setups/debugging.nix +++ b/configs/nixvim/fiesta/modules/setups/debugging.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.fiesta; cfg = nixvimCfg.setups.debugging; -in -{ +in { options.nixvimConfigs.fiesta.setups.debugging.enable = lib.mkEnableOption "debugging setup for Fiesta NixVim"; @@ -20,125 +19,121 @@ in }; }; - keymaps = - let - bindingPrefix = "d"; - mkDAPBinding = binding: settings: - { - mode = "n"; - key = "${bindingPrefix}${binding}"; - } // settings; - in - lib.mapAttrsToList mkDAPBinding + keymaps = let + bindingPrefix = "d"; + mkDAPBinding = binding: settings: { - "b" = { - options.desc = "Toggle breakpoint"; - action = helpers.mkRaw "require('dap').toggle_breakpoint"; - }; - - "B" = { - options.desc = "Set breakpoint"; - action = helpers.mkRaw "require('dap').set_breakpoint"; - }; - - "Bp" = { - options.desc = "Set breakpoint with log message"; - action = helpers.mkRaw '' - function() - require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) - end - ''; - }; - - "n" = { - options.desc = "Continue"; - action = helpers.mkRaw "require('dap').continue"; - }; - - # You know, like a comma is supposed to do. I got nothing on this one - # but this is the best choice for now. - "," = { - options.desc = "Pause"; - action = helpers.mkRaw "require('dap').pause"; - }; - - "d" = { - options.desc = "Terminate"; - action = helpers.mkRaw "require('dap').terminate"; - }; - - "l" = { - options.desc = "Step over"; - action = helpers.mkRaw "require('dap').step_over"; - }; - - "j" = { - options.desc = "Step into"; - action = helpers.mkRaw "require('dap').step_into"; - }; - - "J" = { - options.desc = "Go up"; - action = helpers.mkRaw "require('dap').up"; - }; - - "k" = { - options.desc = "Step out"; - action = helpers.mkRaw "require('dap').step_out"; - }; - - "K" = { - options.desc = "Go down"; - action = helpers.mkRaw "require('dap').down"; - }; - - "rs" = { - options.desc = "Restart session"; - action = helpers.mkRaw "require('dap').restart"; - }; - - "rr" = { - options.desc = "Open debugging REPL"; - action = helpers.mkRaw "require('dap').repl.open"; - }; - - "rl" = { - options.desc = "Run last configuration"; - action = helpers.mkRaw "require('dap').run_last"; - }; - - "ph" = { - options.desc = "View the value under the cursor"; - action = helpers.mkRaw "require('dap.ui.widgets').hover"; - mode = [ "n" "v" ]; - }; - - "pp" = { - options.desc = "See value in preview window"; - action = helpers.mkRaw "require('dap.ui.widgets').preview"; - mode = [ "n" "v" ]; - }; - } - ++ lib.mapAttrsToList mkDAPBinding { - "" = { - options.desc = "Continue"; - action = helpers.mkRaw "require('dap').continue"; - }; - - "" = { - options.desc = "Step over"; - action = helpers.mkRaw "require('dap').step_over"; - }; - - "" = { - options.desc = "Step into"; - action = helpers.mkRaw "require('dap').step_into"; - }; - - "" = { - options.desc = "Step out"; - action = helpers.mkRaw "require('dap').step_out"; - }; + mode = "n"; + key = "${bindingPrefix}${binding}"; + } // settings; + in lib.mapAttrsToList mkDAPBinding { + "b" = { + options.desc = "Toggle breakpoint"; + action = helpers.mkRaw "require('dap').toggle_breakpoint"; }; + + "B" = { + options.desc = "Set breakpoint"; + action = helpers.mkRaw "require('dap').set_breakpoint"; + }; + + "Bp" = { + options.desc = "Set breakpoint with log message"; + action = helpers.mkRaw '' + function() + require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) + end + ''; + }; + + "n" = { + options.desc = "Continue"; + action = helpers.mkRaw "require('dap').continue"; + }; + + # You know, like a comma is supposed to do. I got nothing on this one + # but this is the best choice for now. + "," = { + options.desc = "Pause"; + action = helpers.mkRaw "require('dap').pause"; + }; + + "d" = { + options.desc = "Terminate"; + action = helpers.mkRaw "require('dap').terminate"; + }; + + "l" = { + options.desc = "Step over"; + action = helpers.mkRaw "require('dap').step_over"; + }; + + "j" = { + options.desc = "Step into"; + action = helpers.mkRaw "require('dap').step_into"; + }; + + "J" = { + options.desc = "Go up"; + action = helpers.mkRaw "require('dap').up"; + }; + + "k" = { + options.desc = "Step out"; + action = helpers.mkRaw "require('dap').step_out"; + }; + + "K" = { + options.desc = "Go down"; + action = helpers.mkRaw "require('dap').down"; + }; + + "rs" = { + options.desc = "Restart session"; + action = helpers.mkRaw "require('dap').restart"; + }; + + "rr" = { + options.desc = "Open debugging REPL"; + action = helpers.mkRaw "require('dap').repl.open"; + }; + + "rl" = { + options.desc = "Run last configuration"; + action = helpers.mkRaw "require('dap').run_last"; + }; + + "ph" = { + options.desc = "View the value under the cursor"; + action = helpers.mkRaw "require('dap.ui.widgets').hover"; + mode = [ "n" "v" ]; + }; + + "pp" = { + options.desc = "See value in preview window"; + action = helpers.mkRaw "require('dap.ui.widgets').preview"; + mode = [ "n" "v" ]; + }; + } ++ lib.mapAttrsToList mkDAPBinding { + "" = { + options.desc = "Continue"; + action = helpers.mkRaw "require('dap').continue"; + }; + + "" = { + options.desc = "Step over"; + action = helpers.mkRaw "require('dap').step_over"; + }; + + "" = { + options.desc = "Step into"; + action = helpers.mkRaw "require('dap').step_into"; + }; + + "" = { + options.desc = "Step out"; + action = helpers.mkRaw "require('dap').step_out"; + }; + }; }; } diff --git a/configs/nixvim/fiesta/modules/setups/desktop-utils.nix b/configs/nixvim/fiesta/modules/setups/desktop-utils.nix index 29fe7e5d..2509b31f 100644 --- a/configs/nixvim/fiesta/modules/setups/desktop-utils.nix +++ b/configs/nixvim/fiesta/modules/setups/desktop-utils.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.fiesta; cfg = nixvimCfg.setups.desktop-utils; -in -{ +in { options.nixvimConfigs.fiesta.setups.desktop-utils.enable = lib.mkEnableOption "desktop utilities to be used for this Neovim setup"; diff --git a/configs/nixvim/fiesta/modules/setups/devenvs.nix b/configs/nixvim/fiesta/modules/setups/devenvs.nix index c979134b..f7517628 100644 --- a/configs/nixvim/fiesta/modules/setups/devenvs.nix +++ b/configs/nixvim/fiesta/modules/setups/devenvs.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.fiesta; cfg = nixvimCfg.setups.devenvs; -in -{ +in { options.nixvimConfigs.fiesta.setups.devenvs.enable = lib.mkEnableOption "integration for typical devenvs"; diff --git a/configs/nixvim/fiesta/modules/setups/fuzzy-finder.nix b/configs/nixvim/fiesta/modules/setups/fuzzy-finder.nix index 3a6a5f74..1bd33f6f 100644 --- a/configs/nixvim/fiesta/modules/setups/fuzzy-finder.nix +++ b/configs/nixvim/fiesta/modules/setups/fuzzy-finder.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.fiesta; cfg = nixvimCfg.setups.fuzzy-finder; -in -{ +in { options.nixvimConfigs.fiesta.setups.fuzzy-finder.enable = lib.mkEnableOption "fuzzy finder setup"; @@ -17,68 +16,63 @@ in }; # Configure all of the keymaps. - keymaps = - let - bindingPrefix = "f"; - mkTelescopeKeymap = binding: settings: - lib.mergeAttrs - { - mode = "n"; - key = "${bindingPrefix}${binding}"; + keymaps = let + bindingPrefix = "f"; + mkTelescopeKeymap = binding: settings: + lib.mergeAttrs { + mode = "n"; + key = "${bindingPrefix}${binding}"; + } settings; + in lib.mapAttrsToList mkTelescopeKeymap ({ + "A" = { + options.desc = "Resume from last use"; + action = helpers.mkRaw "require('telescope.builtin').resume"; + }; + "b" = { + options.desc = "List buffers"; + action = helpers.mkRaw "require('telescope.builtin').buffers"; + }; + "f" = { + options.desc = "Find files"; + action = helpers.mkRaw '' + function() + require('telescope.builtin').find_files { hidden = true } + end + ''; + }; + "F" = { + options.desc = "Find files in current directory"; + action = helpers.mkRaw '' + function() + require('telescope.builtin').find_files { + cwd = require('telescope.utils').buffer_dir(), + hidden = true, } - settings; - in - lib.mapAttrsToList mkTelescopeKeymap ({ - "A" = { - options.desc = "Resume from last use"; - action = helpers.mkRaw "require('telescope.builtin').resume"; - }; - "b" = { - options.desc = "List buffers"; - action = helpers.mkRaw "require('telescope.builtin').buffers"; - }; - "f" = { - options.desc = "Find files"; - action = helpers.mkRaw '' - function() - require('telescope.builtin').find_files { hidden = true } - end - ''; - }; - "F" = { - options.desc = "Find files in current directory"; - action = helpers.mkRaw '' - function() - require('telescope.builtin').find_files { - cwd = require('telescope.utils').buffer_dir(), - hidden = true, - } - end - ''; - }; - "v" = { - options.desc = "Find files tracked by Git"; - action = helpers.mkRaw "require('telescope.builtin').git_files"; - }; - "g" = { - options.desc = "Live grep for the whole project"; - action = helpers.mkRaw "require('telescope.builtin').live_grep"; - }; - "h" = { - options.desc = "Find section from help tags"; - action = helpers.mkRaw "require('telescope.builtin').help_tags"; - }; - "m" = { - options.desc = "Find manpage entries"; - action = helpers.mkRaw "require('telescope.builtin').man_pages"; - }; - } - // lib.optionalAttrs nixvimCfg.setups.treesitter.enable { - "t" = { - options.desc = "List symbols from treesitter queries"; - action = helpers.mkRaw "require('telescope.builtin').treesitter"; - }; - }); + end + ''; + }; + "v" = { + options.desc = "Find files tracked by Git"; + action = helpers.mkRaw "require('telescope.builtin').git_files"; + }; + "g" = { + options.desc = "Live grep for the whole project"; + action = helpers.mkRaw "require('telescope.builtin').live_grep"; + }; + "h" = { + options.desc = "Find section from help tags"; + action = helpers.mkRaw "require('telescope.builtin').help_tags"; + }; + "m" = { + options.desc = "Find manpage entries"; + action = helpers.mkRaw "require('telescope.builtin').man_pages"; + }; + } // lib.optionalAttrs nixvimCfg.setups.treesitter.enable { + "t" = { + options.desc = "List symbols from treesitter queries"; + action = helpers.mkRaw "require('telescope.builtin').treesitter"; + }; + }); }; } diff --git a/configs/nixvim/fiesta/modules/setups/lsp.nix b/configs/nixvim/fiesta/modules/setups/lsp.nix index 7571c0e7..f5f4c537 100644 --- a/configs/nixvim/fiesta/modules/setups/lsp.nix +++ b/configs/nixvim/fiesta/modules/setups/lsp.nix @@ -3,30 +3,26 @@ let nixvimConfig = config.nixvimConfigs.fiesta; cfg = nixvimConfig.setups.lsp; -in -{ - options.nixvimConfigs.fiesta.setups.lsp.enable = - lib.mkEnableOption null // { - description = '' - Whether to enable LSP setup. Take note you'll have to enable and - configure individual language servers yourself since the resulting - NixVim config can be pretty heavy. - ''; - }; +in { + options.nixvimConfigs.fiesta.setups.lsp.enable = lib.mkEnableOption null // { + description = '' + Whether to enable LSP setup. Take note you'll have to enable and + configure individual language servers yourself since the resulting + NixVim config can be pretty heavy. + ''; + }; config = lib.mkIf cfg.enable { - keymaps = [ - { - mode = [ "n" ]; - key = "Li"; - options.desc = "Toggle inlay hints"; - action = helpers.mkRaw '' - function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) - end - ''; - } - ]; + keymaps = [{ + mode = [ "n" ]; + key = "Li"; + options.desc = "Toggle inlay hints"; + action = helpers.mkRaw '' + function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) + end + ''; + }]; plugins.lsp = { enable = true; diff --git a/configs/nixvim/fiesta/modules/setups/note-taking.nix b/configs/nixvim/fiesta/modules/setups/note-taking.nix index 281dc678..ab4f333f 100644 --- a/configs/nixvim/fiesta/modules/setups/note-taking.nix +++ b/configs/nixvim/fiesta/modules/setups/note-taking.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.fiesta; cfg = nixvimCfg.setups.note-taking; -in -{ +in { options.nixvimConfigs.fiesta.setups.note-taking.enable = lib.mkEnableOption "basic note-taking setup"; @@ -25,11 +24,10 @@ in # Install the tree-sitter parsers. plugins.treesitter.grammarPackages = - lib.mkIf - (config.plugins.neorg.settings ? load."core.defaults") - (with pkgs.tree-sitter-grammars; [ - tree-sitter-norg - tree-sitter-norg-meta - ]); + lib.mkIf (config.plugins.neorg.settings ? load."core.defaults") + (with pkgs.tree-sitter-grammars; [ + tree-sitter-norg + tree-sitter-norg-meta + ]); }; } diff --git a/configs/nixvim/fiesta/modules/setups/qol.nix b/configs/nixvim/fiesta/modules/setups/qol.nix index 7f37e1da..4c57a1fb 100644 --- a/configs/nixvim/fiesta/modules/setups/qol.nix +++ b/configs/nixvim/fiesta/modules/setups/qol.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.fiesta; cfg = nixvimCfg.setups.devenvs; -in -{ +in { options.nixvimConfigs.fiesta.setups.qol.enable = lib.mkEnableOption "quality-of-life improvements"; diff --git a/configs/nixvim/fiesta/modules/setups/snippets/default.nix b/configs/nixvim/fiesta/modules/setups/snippets/default.nix index 114f7101..fa1e45bf 100644 --- a/configs/nixvim/fiesta/modules/setups/snippets/default.nix +++ b/configs/nixvim/fiesta/modules/setups/snippets/default.nix @@ -4,11 +4,8 @@ let nixvimCfg = config.nixvimConfigs.fiesta; cfg = nixvimCfg.setups.snippets; - luasnipKeymapConfig = { - mode = [ "i" "s" ]; - }; -in -{ + luasnipKeymapConfig = { mode = [ "i" "s" ]; }; +in { options.nixvimConfigs.fiesta.setups.snippets.enable = lib.mkEnableOption "snippets setup"; @@ -26,12 +23,10 @@ in plugins.friendly-snippets.enable = true; # Load all of the custom snippets. - plugins.luasnip.fromLua = [ - { - lazyLoad = true; - paths = ./snippets; - } - ]; + plugins.luasnip.fromLua = [{ + lazyLoad = true; + paths = ./snippets; + }]; # Set up the keymaps ourselves since LuaSnip doesn't provide one as a # config option. diff --git a/configs/nixvim/fiesta/modules/setups/treesitter.nix b/configs/nixvim/fiesta/modules/setups/treesitter.nix index 6efc1789..f98ead59 100644 --- a/configs/nixvim/fiesta/modules/setups/treesitter.nix +++ b/configs/nixvim/fiesta/modules/setups/treesitter.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.fiesta; cfg = nixvimCfg.setups.treesitter; -in -{ +in { options.nixvimConfigs.fiesta.setups.treesitter.enable = lib.mkEnableOption "tree-sitter setup for Fiesta NixVim"; @@ -41,87 +40,99 @@ in lspInterop = { enable = true; border = "none"; - peekDefinitionCode = - let - bindingPrefix = "d"; + peekDefinitionCode = let + bindingPrefix = "d"; - mkQueryMappings = query: binding: - lib.nameValuePair "${bindingPrefix}${binding}" { - desc = "Peek definition of ${query}"; - query = "@${query}.outer"; - }; - in - lib.mapAttrs' mkQueryMappings { - "function" = "f"; - "class" = "F"; - }; + mkQueryMappings = query: binding: + lib.nameValuePair "${bindingPrefix}${binding}" { + desc = "Peek definition of ${query}"; + query = "@${query}.outer"; + }; + in lib.mapAttrs' mkQueryMappings { + "function" = "f"; + "class" = "F"; + }; }; move = lib.mkMerge ([{ enable = true; setJumps = true; - }] - ++ ( - let - motions = lib.cartesianProduct { - region = [ "Start" "End" ]; - jumpDirection = [ "Previous" "Next" ]; - variant = [ "outer" "inner" ]; - }; + }] ++ (let + motions = lib.cartesianProduct { + region = [ "Start" "End" ]; + jumpDirection = [ "Previous" "Next" ]; + variant = [ "outer" "inner" ]; + }; - motionMap = { - outerPrevious = "["; - outerNext = "]"; - innerPrevious = "[["; - innerNext = "]]"; - }; + motionMap = { + outerPrevious = "["; + outerNext = "]"; + innerPrevious = "[["; + innerNext = "]]"; + }; - actionDesc = variant: jumpDirection: query: - if variant == "inner" - then "Jump to inner part of the ${jumpDirection} ${query}" - else "Jump to ${jumpDirection} ${query}"; + actionDesc = variant: jumpDirection: query: + if variant == "inner" then + "Jump to inner part of the ${jumpDirection} ${query}" + else + "Jump to ${jumpDirection} ${query}"; - mkQueryMappings = - # The accumulator. Should be a list where it contains all of the - # modules to be merged. - acc: + mkQueryMappings = + # The accumulator. Should be a list where it contains all of the + # modules to be merged. + acc: - # The query object of the treesitter node. All queries are - # assumed to be "@$QUERY.outer". - query: + # The query object of the treesitter node. All queries are + # assumed to be "@$QUERY.outer". + query: - # A set of bindings to be used for each jump direction. - bindings: - let - mappings = builtins.map - (motion: - let - inherit (motion) region jumpDirection variant; - jumpDirection' = lib.strings.toLower jumpDirection; - binding' = bindings.${jumpDirection'}; - bindingPrefix = motionMap."${variant}${jumpDirection}"; - in - { - "goto${jumpDirection}${region}" = { - "${bindingPrefix}${binding'}" = { - desc = actionDesc variant jumpDirection' query; - query = "@${query}.${variant}"; - }; - }; - }) - motions; - in - acc ++ mappings; - in - lib.foldlAttrs mkQueryMappings [ ] { - "function" = { previous = "M"; next = "m"; }; - "block" = { previous = "B"; next = "b"; }; - "call" = { previous = "F"; next = "f"; }; - "class" = { previous = "C"; next = "c"; }; - "conditional" = { previous = "D"; next = "d"; }; - "statement" = { previous = "S"; next = "s"; }; - "loop" = { previous = "L"; next = "l"; }; - } - )); + # A set of bindings to be used for each jump direction. + bindings: + let + mappings = builtins.map (motion: + let + inherit (motion) region jumpDirection variant; + jumpDirection' = lib.strings.toLower jumpDirection; + binding' = bindings.${jumpDirection'}; + bindingPrefix = motionMap."${variant}${jumpDirection}"; + in { + "goto${jumpDirection}${region}" = { + "${bindingPrefix}${binding'}" = { + desc = actionDesc variant jumpDirection' query; + query = "@${query}.${variant}"; + }; + }; + }) motions; + in acc ++ mappings; + in lib.foldlAttrs mkQueryMappings [ ] { + "function" = { + previous = "M"; + next = "m"; + }; + "block" = { + previous = "B"; + next = "b"; + }; + "call" = { + previous = "F"; + next = "f"; + }; + "class" = { + previous = "C"; + next = "c"; + }; + "conditional" = { + previous = "D"; + next = "d"; + }; + "statement" = { + previous = "S"; + next = "s"; + }; + "loop" = { + previous = "L"; + next = "l"; + }; + })); select = { enable = true; lookahead = true; @@ -130,101 +141,94 @@ in "@class.outer" = ""; "@block.outer" = ""; }; - keymaps = - let - prefixMap = { - "outer" = { - key = "a"; - desc = query: "Select around the ${query} region"; - }; - "inner" = { - key = "i"; - desc = query: "Select inner part of the ${query} region"; - }; + keymaps = let + prefixMap = { + "outer" = { + key = "a"; + desc = query: "Select around the ${query} region"; + }; + "inner" = { + key = "i"; + desc = query: "Select inner part of the ${query} region"; }; - - # A function that creates a pair of keymaps: one for the outer and - # inner part of the query. As such, it assumes the query has an - # outer and inner variant. - mkQueryMappings = - # The textobject query, assumed as "@$QUERY.$VARIANT". - query: - - # The keymap sequence to affix for the mapping pair. - binding: - - let - mappingsList = - builtins.map - (variant: - let - prefixMap' = prefixMap.${variant}; - in - lib.nameValuePair "${prefixMap'.key}${binding}" { - query = "@${query}.${variant}"; - desc = prefixMap'.desc query; - }) [ "outer" "inner" ]; - in - lib.listToAttrs mappingsList; - in - lib.concatMapAttrs mkQueryMappings { - "function" = "m"; - "call" = "f"; - "class" = "c"; - "block" = "b"; - "loop" = "l"; - "statement" = "s"; - "attribute" = "a"; }; + + # A function that creates a pair of keymaps: one for the outer and + # inner part of the query. As such, it assumes the query has an + # outer and inner variant. + mkQueryMappings = + # The textobject query, assumed as "@$QUERY.$VARIANT". + query: + + # The keymap sequence to affix for the mapping pair. + binding: + + let + mappingsList = builtins.map (variant: + let prefixMap' = prefixMap.${variant}; + in lib.nameValuePair "${prefixMap'.key}${binding}" { + query = "@${query}.${variant}"; + desc = prefixMap'.desc query; + }) [ "outer" "inner" ]; + in lib.listToAttrs mappingsList; + in lib.concatMapAttrs mkQueryMappings { + "function" = "m"; + "call" = "f"; + "class" = "c"; + "block" = "b"; + "loop" = "l"; + "statement" = "s"; + "attribute" = "a"; + }; }; - swap = lib.mkMerge ( - [{ enable = true; }] - ++ ( + swap = lib.mkMerge ([{ enable = true; }] ++ (let + motions = lib.cartesianProduct { + jumpDirection = [ "Previous" "Next" ]; + variant = [ "outer" ]; + }; + + motionMap = { + "outerPrevious" = "S"; + "outerNext" = "s"; + }; + + actionDesc = variant: jumpDirection: query: + if variant == "inner" then + "Jump to inner part of the ${jumpDirection} ${query}" + else + "Jump to ${jumpDirection} ${query}"; + + mkQueryMappings = acc: query: bindings: let - motions = lib.cartesianProduct { - jumpDirection = [ "Previous" "Next" ]; - variant = [ "outer" ]; - }; - - motionMap = { - "outerPrevious" = "S"; - "outerNext" = "s"; - }; - - actionDesc = variant: jumpDirection: query: - if variant == "inner" - then "Jump to inner part of the ${jumpDirection} ${query}" - else "Jump to ${jumpDirection} ${query}"; - - mkQueryMappings = acc: query: bindings: + mappings = builtins.map (motion: let - mappings = builtins.map - (motion: - let - inherit (motion) jumpDirection variant; - jumpDirection' = lib.strings.toLower jumpDirection; - binding' = bindings.${jumpDirection'}; - bindingPrefix = motionMap."${variant}${jumpDirection}"; - in - { - "swap${jumpDirection}" = { - "${bindingPrefix}${binding'}" = { - desc = actionDesc variant jumpDirection' query; - query = "@${query}.${variant}"; - }; - }; - }) - motions; - in - acc ++ mappings; - in - lib.foldlAttrs mkQueryMappings [ ] { - "function" = { next = "f"; previous = "F"; }; - "parameter" = { next = "a"; previous = "A"; }; - "conditional" = { next = "d"; previous = "D"; }; - } - ) - ); + inherit (motion) jumpDirection variant; + jumpDirection' = lib.strings.toLower jumpDirection; + binding' = bindings.${jumpDirection'}; + bindingPrefix = motionMap."${variant}${jumpDirection}"; + in { + "swap${jumpDirection}" = { + "${bindingPrefix}${binding'}" = { + desc = actionDesc variant jumpDirection' query; + query = "@${query}.${variant}"; + }; + }; + }) motions; + in acc ++ mappings; + in lib.foldlAttrs mkQueryMappings [ ] { + "function" = { + next = "f"; + previous = "F"; + }; + "parameter" = { + next = "a"; + previous = "A"; + }; + "conditional" = { + next = "d"; + previous = "D"; + }; + })); }; }; } diff --git a/configs/nixvim/fiesta/modules/setups/ui.nix b/configs/nixvim/fiesta/modules/setups/ui.nix index ba29d663..01bdd22e 100644 --- a/configs/nixvim/fiesta/modules/setups/ui.nix +++ b/configs/nixvim/fiesta/modules/setups/ui.nix @@ -1,10 +1,9 @@ -{ config, lib, helpers,... }: +{ config, lib, helpers, ... }: let nixvimCfg = config.nixvimConfigs.fiesta; cfg = nixvimCfg.setups.ui; -in -{ +in { options.nixvimConfigs.fiesta.setups.ui.enable = lib.mkEnableOption "configuration for UI-related settings and plugins"; @@ -46,9 +45,7 @@ in plugins.indent-blankline = { enable = true; settings = { - indent = { - char = "┊"; - }; + indent = { char = "┊"; }; scope.char = "┃"; }; }; diff --git a/configs/nixvim/trovebelt/modules/setups/debugging.nix b/configs/nixvim/trovebelt/modules/setups/debugging.nix index 7ebf5386..14dbc51a 100644 --- a/configs/nixvim/trovebelt/modules/setups/debugging.nix +++ b/configs/nixvim/trovebelt/modules/setups/debugging.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.trovebelt; cfg = nixvimCfg.setups.debugging; -in -{ +in { options.nixvimConfigs.trovebelt.setups.debugging.enable = lib.mkEnableOption "debugging setup"; @@ -19,9 +18,7 @@ in args = [ "-i" "dap" ]; }; - lldb = { - command = "lldb-dap"; - }; + lldb = { command = "lldb-dap"; }; dart = { command = "dart"; @@ -37,6 +34,5 @@ in # Enable all of the debugging extensoins. plugins.dap.extensions.dap-go.enable = true; plugins.dap.extensions.dap-python.enable = true; - plugins.rustaceanvim.enable = true; }; } diff --git a/configs/nixvim/trovebelt/modules/setups/lsp.nix b/configs/nixvim/trovebelt/modules/setups/lsp.nix index d2290fc0..313f71eb 100644 --- a/configs/nixvim/trovebelt/modules/setups/lsp.nix +++ b/configs/nixvim/trovebelt/modules/setups/lsp.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.trovebelt; cfg = nixvimCfg.setups.lsp; -in -{ +in { options.nixvimConfigs.trovebelt.setups.lsp.enable = lib.mkEnableOption "LSP setup alongside the preferred servers installation"; @@ -12,60 +11,59 @@ in plugins.lsp.enable = true; # Make all of the preferred language servers. - plugins.lsp.servers = - let - servers = [ - "ansiblels" # For Ansible. - "astro" # For Astro. - "beancount" # For Beancount. - "bashls" # For Bash. - "clangd" # For C/C++. - "clojure-lsp" # For Clojure. - "cmake" # For CMake. - "cssls" # For CSS. - "dagger" # For Dagger. - "dartls" # For Dart. - "denols" # For Deno. - "dhall-lsp-server" # For Dhall. - "dockerls" # For Dockerfiles. - "efm" # For whatever. - "elixirls" # For Elixir. - "elmls" # For Elm. - "emmet-ls" # For Emmet support. - "eslint" # For JavaScript. - "gdscript" # For Godot. - "gopls" # For Go. - "graphql" # For GraphQL. - "hls" # For Haskell. - "html" # For HTML. - "htmx" # For HTMX. - "java-language-server" # For Java. - "jsonls" # For JSON. - "julials" # For Julia. - "kotlin-language-server" # For Kotlin. - "lemminx" # For XML. - "lua-ls" # For Lua. - "nil-ls" # For Nix. - "nushell" # For Nushell. - "perlpls" # For Perl. - "phpactor" # For PHP. - "pyright" # For Python. - "rust-analyzer" # For Rust. - "solargraph" # For Ruby. - "svelte" # For Svelte. - "taplo" # For TOML. - "tailwindcss" # For Tailwind CSS. - "terraformls" # For Terraform. - "tsserver" # For TypeScript. - "typst-lsp" # For Typst. - "vls" # For V. - "volar" # For Vue. - "yamlls" # For YAML. - "zls" # For Zig. - ]; + plugins.lsp.servers = let + servers = [ + "ansiblels" # For Ansible. + "astro" # For Astro. + "beancount" # For Beancount. + "bashls" # For Bash. + "clangd" # For C/C++. + "clojure-lsp" # For Clojure. + "cmake" # For CMake. + "cssls" # For CSS. + "dagger" # For Dagger. + "dartls" # For Dart. + "denols" # For Deno. + "dhall-lsp-server" # For Dhall. + "dockerls" # For Dockerfiles. + "efm" # For whatever. + "elixirls" # For Elixir. + "elmls" # For Elm. + "emmet-ls" # For Emmet support. + "eslint" # For JavaScript. + "gdscript" # For Godot. + "gopls" # For Go. + "graphql" # For GraphQL. + "hls" # For Haskell. + "html" # For HTML. + "htmx" # For HTMX. + "java-language-server" # For Java. + "jsonls" # For JSON. + "julials" # For Julia. + "kotlin-language-server" # For Kotlin. + "lemminx" # For XML. + "lua-ls" # For Lua. + "nil-ls" # For Nix. + "nushell" # For Nushell. + "perlpls" # For Perl. + "phpactor" # For PHP. + "pyright" # For Python. + "rust-analyzer" # For Rust. + "solargraph" # For Ruby. + "svelte" # For Svelte. + "taplo" # For TOML. + "tailwindcss" # For Tailwind CSS. + "terraformls" # For Terraform. + "tsserver" # For TypeScript. + "typst-lsp" # For Typst. + "vls" # For V. + "volar" # For Vue. + "yamlls" # For YAML. + "zls" # For Zig. + ]; - mkEnableServerConfig = server: lib.nameValuePair server { enable = true; }; - in - lib.listToAttrs (builtins.map mkEnableServerConfig servers); + mkEnableServerConfig = server: + lib.nameValuePair server { enable = true; }; + in lib.listToAttrs (builtins.map mkEnableServerConfig servers); }; } diff --git a/configs/nixvim/trovebelt/modules/setups/treesitter.nix b/configs/nixvim/trovebelt/modules/setups/treesitter.nix index c928794b..a2a678cd 100644 --- a/configs/nixvim/trovebelt/modules/setups/treesitter.nix +++ b/configs/nixvim/trovebelt/modules/setups/treesitter.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.trovebelt; cfg = nixvimCfg.setups.treesitter; -in -{ +in { options.nixvimConfigs.trovebelt.setups.treesitter.enable = lib.mkEnableOption "tree-sitter setup with all parsers installed"; diff --git a/configs/nixvim/trovebelt/modules/setups/ui.nix b/configs/nixvim/trovebelt/modules/setups/ui.nix index 8b28a9bc..b4c987ae 100644 --- a/configs/nixvim/trovebelt/modules/setups/ui.nix +++ b/configs/nixvim/trovebelt/modules/setups/ui.nix @@ -3,8 +3,7 @@ let nixvimCfg = config.nixvimConfigs.trovebelt; cfg = nixvimCfg.setups.ui; -in -{ +in { options.nixvimConfigs.trovebelt.setups.ui.enable = lib.mkEnableOption "configuration for UI-related settings and plugins"; diff --git a/configs/wrapper-manager/archive-setup/default.nix b/configs/wrapper-manager/archive-setup/default.nix index ec74aa59..29edaab3 100644 --- a/configs/wrapper-manager/archive-setup/default.nix +++ b/configs/wrapper-manager/archive-setup/default.nix @@ -3,15 +3,11 @@ { wrappers.yt-dlp-audio = { arg0 = lib.getExe' pkgs.yt-dlp "yt-dlp"; - prependArgs = [ - "--config-location" ./config/yt-dlp/audio.conf - ]; + prependArgs = [ "--config-location" ./config/yt-dlp/audio.conf ]; }; wrappers.yt-dlp-video = { arg0 = lib.getExe' pkgs.yt-dlp "yt-dlp"; - prependArgs = [ - "--config-location" ./config/yt-dlp/video.conf - ]; + prependArgs = [ "--config-location" ./config/yt-dlp/video.conf ]; }; } diff --git a/default.nix b/default.nix index bfb48211..b0431d6e 100644 --- a/default.nix +++ b/default.nix @@ -1,14 +1,8 @@ { compat-flake ? "flake-compat-fds" }: -(import - ( - let - lock = builtins.fromJSON (builtins.readFile ./flake.lock); - in - fetchTarball { - url = lock.nodes.${compat-flake}.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.${compat-flake}.locked.narHash; - } - ) - { src = ./.; } -).defaultNix +(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock); +in fetchTarball { + url = + lock.nodes.${compat-flake}.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.${compat-flake}.locked.narHash; +}) { src = ./.; }).defaultNix diff --git a/docs/default.nix b/docs/default.nix index 422948f5..65d59e55 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -3,82 +3,71 @@ let inherit (pkgs) lib nixosOptionsDoc; - mkOptionsDoc = args@{ class, modules, includeModuleSystemArguments ? false, ... }: + mkOptionsDoc = + args@{ class, modules, includeModuleSystemArguments ? false, ... }: let - modulesEval = - if class == "nixos" - then lib.evalModules { - modules = modules ++ lib.singleton { - imports = [ - "${pkgs.path}/nixos/modules/misc/extra-arguments.nix" + modulesEval = if class == "nixos" then + lib.evalModules { + modules = modules ++ lib.singleton { + imports = [ + "${pkgs.path}/nixos/modules/misc/extra-arguments.nix" - # One of the modules requires this to be included. - "${pkgs.path}/nixos/modules/config/xdg/mime.nix" - ]; - _module.check = false; - _module.args.pkgs = pkgs; - fileSystems."/".device = "nodev"; - }; - } - else if class == "homeManager" - then - let - hmLib = import lib; - in - lib.evalModules { - modules = modules ++ lib.singleton { - _module.check = false; - _module.args.pkgs = pkgs; - lib = hmLib.hm; - }; - } - else if class == "wrapperManager" then - let - wrapper-manager = import ../subprojects/wrapper-manager-fds { }; - in - wrapper-manager.lib.eval { - inherit pkgs; - modules = modules ++ lib.singleton { - _module.check = false; - }; - } - else - lib.evalModules { - modules = modules ++ lib.singleton { - _module.check = false; - _module.args.pkgs = pkgs; - }; + # One of the modules requires this to be included. + "${pkgs.path}/nixos/modules/config/xdg/mime.nix" + ]; + _module.check = false; + _module.args.pkgs = pkgs; + fileSystems."/".device = "nodev"; }; + } + else if class == "homeManager" then + let hmLib = import lib; + in lib.evalModules { + modules = modules ++ lib.singleton { + _module.check = false; + _module.args.pkgs = pkgs; + lib = hmLib.hm; + }; + } + else if class == "wrapperManager" then + let wrapper-manager = import ../subprojects/wrapper-manager-fds { }; + in wrapper-manager.lib.eval { + inherit pkgs; + modules = modules ++ lib.singleton { _module.check = false; }; + } + else + lib.evalModules { + modules = modules ++ lib.singleton { + _module.check = false; + _module.args.pkgs = pkgs; + }; + }; inherit (modulesEval) options; - in - nixosOptionsDoc ({ - options = - if includeModuleSystemArguments - then options - else builtins.removeAttrs options [ "_module" ]; - } - // builtins.removeAttrs args [ "modules" "class" "includeModuleSystemArguments" ]); + in nixosOptionsDoc ({ + options = if includeModuleSystemArguments then + options + else + builtins.removeAttrs options [ "_module" ]; + } // builtins.removeAttrs args [ + "modules" + "class" + "includeModuleSystemArguments" + ]); mkManpage = { optionsJSON, asciidocHeader }: - pkgs.runCommand "wrapper-manager-reference-manpage" - { - nativeBuildInputs = with pkgs; [ - nixos-render-docs - asciidoctor - ]; - } - '' - mkdir -p $out/share/man/man5 - asciidoctor --attribute is-wider-scoped --backend manpage \ - ${asciidocHeader} --out-file header.5 - nixos-render-docs options manpage --revision ${pkgs.lib.version} \ - --header ./header.5 --footer ${./manpages/footer.5} \ - ${optionsJSON}/share/doc/nixos/options.json \ - $out/share/man/man5/wrapper-manager.nix.5 - ''; -in -{ + pkgs.runCommand "wrapper-manager-reference-manpage" { + nativeBuildInputs = with pkgs; [ nixos-render-docs asciidoctor ]; + } '' + mkdir -p $out/share/man/man5 + asciidoctor --attribute is-wider-scoped --backend manpage \ + ${asciidocHeader} --out-file header.5 + nixos-render-docs options manpage --revision ${pkgs.lib.version} \ + --header ./header.5 --footer ${./manpages/footer.5} \ + ${optionsJSON}/share/doc/nixos/options.json \ + $out/share/man/man5/wrapper-manager.nix.5 + ''; +in { nixos = rec { optionsDoc = mkOptionsDoc { modules = [ ../modules/nixos ../modules/nixos/_private ]; @@ -117,7 +106,8 @@ in wrapper-manager = rec { optionsDoc = mkOptionsDoc { - modules = [ ../modules/wrapper-manager ../modules/wrapper-manager/_private ]; + modules = + [ ../modules/wrapper-manager ../modules/wrapper-manager/_private ]; class = "wrapperManager"; }; diff --git a/docs/website/content/en/03-project-specific-setup/03-secrets-management/assets/attach-sops-prefix.nix b/docs/website/content/en/03-project-specific-setup/03-secrets-management/assets/attach-sops-prefix.nix index 95588d8b..3e44a127 100644 --- a/docs/website/content/en/03-project-specific-setup/03-secrets-management/assets/attach-sops-prefix.nix +++ b/docs/website/content/en/03-project-specific-setup/03-secrets-management/assets/attach-sops-prefix.nix @@ -1,18 +1,14 @@ { config, lib, pkgs, ... }: { - sops.secrets = - lib.getSecrets ./sops.yaml - { - ssh-key = { }; - "borg/ssh-key" = { }; - } // - (lib.getSecrets ./wireguard.yaml - (lib.attachSopsPathPrefix "wireguard" { - "private-key" = { - group = config.users.users.systemd-network.group; - reloadUnits = [ "systemd-networkd.service" ]; - mode = "0640"; - }; - })); + sops.secrets = lib.getSecrets ./sops.yaml { + ssh-key = { }; + "borg/ssh-key" = { }; + } // (lib.getSecrets ./wireguard.yaml (lib.attachSopsPathPrefix "wireguard" { + "private-key" = { + group = config.users.users.systemd-network.group; + reloadUnits = [ "systemd-networkd.service" ]; + mode = "0640"; + }; + })); } diff --git a/docs/website/gemset.nix b/docs/website/gemset.nix index 541e984c..310e4ef9 100644 --- a/docs/website/gemset.nix +++ b/docs/website/gemset.nix @@ -10,7 +10,12 @@ version = "2.0.20"; }; asciidoctor-diagram = { - dependencies = [ "asciidoctor" "asciidoctor-diagram-ditaamini" "asciidoctor-diagram-plantuml" "rexml" ]; + dependencies = [ + "asciidoctor" + "asciidoctor-diagram-ditaamini" + "asciidoctor-diagram-plantuml" + "rexml" + ]; groups = [ "default" ]; platforms = [ ]; source = { @@ -193,7 +198,18 @@ version = "4.1.2"; }; rubocop = { - dependencies = [ "json" "language_server-protocol" "parallel" "parser" "rainbow" "regexp_parser" "rexml" "rubocop-ast" "ruby-progressbar" "unicode-display_width" ]; + dependencies = [ + "json" + "language_server-protocol" + "parallel" + "parser" + "rainbow" + "regexp_parser" + "rexml" + "rubocop-ast" + "ruby-progressbar" + "unicode-display_width" + ]; groups = [ "lint" ]; platforms = [ ]; source = { @@ -215,7 +231,8 @@ version = "1.29.0"; }; ruby-lsp = { - dependencies = [ "language_server-protocol" "sorbet-runtime" "syntax_tree" ]; + dependencies = + [ "language_server-protocol" "sorbet-runtime" "syntax_tree" ]; groups = [ "development" ]; platforms = [ ]; source = { diff --git a/docs/website/package.nix b/docs/website/package.nix index 01877a9d..6219e253 100644 --- a/docs/website/package.nix +++ b/docs/website/package.nix @@ -1,10 +1,4 @@ -{ - lib, - buildHugoSite, - bundlerEnv, - ruby_3_1, - writeShellScriptBin, -}: +{ lib, buildHugoSite, bundlerEnv, ruby_3_1, writeShellScriptBin, }: let gems = bundlerEnv { @@ -16,8 +10,7 @@ let asciidoctorWrapper = writeShellScriptBin "asciidoctor" '' ${lib.getExe' gems "asciidoctor"} -T ${./assets/templates/asciidoctor} $@ ''; -in -buildHugoSite { +in buildHugoSite { pname = "foodogsquared-docs"; version = "2024-11-21"; diff --git a/docs/website/shell.nix b/docs/website/shell.nix index 204560a6..a36eb516 100644 --- a/docs/website/shell.nix +++ b/docs/website/shell.nix @@ -1,12 +1,7 @@ -{ pkgs ? import { - overlays = [ (import ../../overlays).default ]; -} }: +{ pkgs ? import { overlays = [ (import ../../overlays).default ]; } }: - -let - site = pkgs.callPackage ./package.nix { }; -in -pkgs.mkShell { +let site = pkgs.callPackage ./package.nix { }; +in pkgs.mkShell { inputsFrom = [ site ]; packages = with pkgs; [ diff --git a/flake.nix b/flake.nix index 7b008d73..0cfa50da 100644 --- a/flake.nix +++ b/flake.nix @@ -52,7 +52,8 @@ nixvim-unstable.inputs.home-manager.follows = "home-manager-unstable"; # Make a wrapper. - wrapper-manager-fds.url = "github:foo-dogsquared/nix-module-wrapper-manager-fds"; + wrapper-manager-fds.url = + "github:foo-dogsquared/nix-module-wrapper-manager-fds"; # This is what AUR strives to be. nur.url = "github:nix-community/NUR"; @@ -99,7 +100,8 @@ # Make a default.nix compatible stuff. Take note, we're giving this a # unique suffix since there are other flake inputs that uses the same flake # and we want our `default.nix` to refer to our version. - flake-compat-fds.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; + flake-compat-fds.url = + "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; # Someone had the idea to make the flake outputs be configured as a Nix # module and I love them for it. @@ -108,14 +110,8 @@ outputs = inputs@{ self, nixpkgs, ... }: inputs.flake-parts.lib.mkFlake { inherit inputs; } { - systems = [ - "x86_64-linux" - "aarch64-linux" - ]; + systems = [ "x86_64-linux" "aarch64-linux" ]; - imports = [ - ./modules/flake-parts - ./configs/flake-parts - ]; + imports = [ ./modules/flake-parts ./configs/flake-parts ]; }; } diff --git a/modules/flake-parts/deploy-rs-nodes.nix b/modules/flake-parts/deploy-rs-nodes.nix index 430664bf..3478eab6 100644 --- a/modules/flake-parts/deploy-rs-nodes.nix +++ b/modules/flake-parts/deploy-rs-nodes.nix @@ -9,8 +9,7 @@ let ''; }; }; -in -{ +in { options = { flake = flake-parts-lib.mkSubmoduleOptions { deploy = lib.mkOption { diff --git a/modules/flake-parts/devpackages.nix b/modules/flake-parts/devpackages.nix index 1dbfe218..bf7583e0 100644 --- a/modules/flake-parts/devpackages.nix +++ b/modules/flake-parts/devpackages.nix @@ -1,9 +1,7 @@ { config, lib, flake-parts-lib, ... }: -let - inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption; -in -{ +let inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption; +in { options = { flake = mkSubmoduleOptions { devPackages = lib.mkOption { @@ -31,13 +29,8 @@ in }; config = { - flake.devPackages = - lib.mapAttrs - (k: v: v.devPackages) - (lib.filterAttrs - (k: v: v.devPackages != { }) - config.allSystems - ); + flake.devPackages = lib.mapAttrs (k: v: v.devPackages) + (lib.filterAttrs (k: v: v.devPackages != { }) config.allSystems); perInput = system: flake: lib.optionalAttrs (flake ? devPackages.${system}) { diff --git a/modules/flake-parts/images.nix b/modules/flake-parts/images.nix index 624e4d6b..de7d3c44 100644 --- a/modules/flake-parts/images.nix +++ b/modules/flake-parts/images.nix @@ -3,10 +3,8 @@ # section from the documentation. { config, lib, flake-parts-lib, ... }: -let - inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption; -in -{ +let inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption; +in { options = { flake = mkSubmoduleOptions { images = lib.mkOption { @@ -37,13 +35,8 @@ in }; config = { - flake.images = - lib.mapAttrs - (k: v: v.images) - (lib.filterAttrs - (k: v: v.images != { }) - config.allSystems - ); + flake.images = lib.mapAttrs (k: v: v.images) + (lib.filterAttrs (k: v: v.images != { }) config.allSystems); perInput = system: flake: lib.optionalAttrs (flake ? images.${system}) { diff --git a/modules/flake-parts/nixvim-configurations.nix b/modules/flake-parts/nixvim-configurations.nix index 48d583fb..d3dafaa2 100644 --- a/modules/flake-parts/nixvim-configurations.nix +++ b/modules/flake-parts/nixvim-configurations.nix @@ -1,9 +1,7 @@ { config, lib, flake-parts-lib, ... }: -let - inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption; -in -{ +let inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption; +in { options = { flake = mkSubmoduleOptions { nixvimConfigurations = lib.mkOption { @@ -33,13 +31,8 @@ in }; config = { - flake.nixvimConfigurations = - lib.mapAttrs - (k: v: v.nixvimConfigurations) - (lib.filterAttrs - (k: v: v.nixvimConfigurations != { }) - config.allSystems - ); + flake.nixvimConfigurations = lib.mapAttrs (k: v: v.nixvimConfigurations) + (lib.filterAttrs (k: v: v.nixvimConfigurations != { }) config.allSystems); perInput = system: flake: lib.optionalAttrs (flake ? nixvimConfigurations.${system}) { diff --git a/modules/flake-parts/setups/default.nix b/modules/flake-parts/setups/default.nix index 95968272..e17f3962 100644 --- a/modules/flake-parts/setups/default.nix +++ b/modules/flake-parts/setups/default.nix @@ -35,9 +35,7 @@ module environments based from the nixpkgs module system. ''; default = { }; - example = { - allowUnfree = true; - }; + example = { allowUnfree = true; }; }; sharedSpecialArgs = lib.mkOption { diff --git a/modules/flake-parts/setups/disko.nix b/modules/flake-parts/setups/disko.nix index 1cbcc405..f2648ca6 100644 --- a/modules/flake-parts/setups/disko.nix +++ b/modules/flake-parts/setups/disko.nix @@ -23,15 +23,12 @@ let }; }; }; -in -{ +in { options.setups.disko = { configs = lib.mkOption { type = with lib.types; attrsOf (submodule diskoConfigType); default = { }; - example = { - archive = { }; - }; + example = { archive = { }; }; description = '' A set of declarative Disko configurations only used for integrating with NixOS and itself by exporting into `diskoConfigurations` which is @@ -40,42 +37,37 @@ in }; }; - options.setups.nixos.configs = - let - diskoIntegrationModule = { config, lib, name, ... }: { - options = { - diskoConfigs = lib.mkOption { - type = with lib.types; listOf str; - default = [ ]; - example = [ "external-hdd" ]; - description = '' - A list of declarative Disko configurations to be included alongside - the NixOS configuration. - ''; - }; + options.setups.nixos.configs = let + diskoIntegrationModule = { config, lib, name, ... }: { + options = { + diskoConfigs = lib.mkOption { + type = with lib.types; listOf str; + default = [ ]; + example = [ "external-hdd" ]; + description = '' + A list of declarative Disko configurations to be included alongside + the NixOS configuration. + ''; }; - - config = lib.mkIf (config.diskoConfigs != [ ]) ( - let - diskoConfigs = - builtins.map (name: "${partsConfig.setups.configDir}/disko/${name}") config.diskoConfigs; - in - { - modules = lib.singleton { - imports = - [ inputs.disko.nixosModules.disko ] - ++ diskoConfigs; - }; - } - ); }; - in - lib.mkOption { - type = with lib.types; attrsOf (submodule diskoIntegrationModule); + + config = lib.mkIf (config.diskoConfigs != [ ]) (let + diskoConfigs = + builtins.map (name: "${partsConfig.setups.configDir}/disko/${name}") + config.diskoConfigs; + in { + modules = lib.singleton { + imports = [ inputs.disko.nixosModules.disko ] ++ diskoConfigs; + }; + }); }; + in lib.mkOption { + type = with lib.types; attrsOf (submodule diskoIntegrationModule); + }; config = { - flake.diskoConfigurations = - lib.mapAttrs (name: _: import "${partsConfig.setups.configDir}/disko/${name}") cfg.configs; + flake.diskoConfigurations = lib.mapAttrs + (name: _: import "${partsConfig.setups.configDir}/disko/${name}") + cfg.configs; }; } diff --git a/modules/flake-parts/setups/home-manager.nix b/modules/flake-parts/setups/home-manager.nix index 8812abeb..ebe77e22 100644 --- a/modules/flake-parts/setups/home-manager.nix +++ b/modules/flake-parts/setups/home-manager.nix @@ -9,14 +9,8 @@ let homeManagerModules = ../../home-manager; # A thin wrapper around the home-manager configuration function. - mkHome = - { pkgs - , lib ? pkgs.lib - , system - , homeManagerBranch ? "home-manager" - , extraModules ? [ ] - , specialArgs ? { } - }: + mkHome = { pkgs, lib ? pkgs.lib, system, homeManagerBranch ? "home-manager" + , extraModules ? [ ], specialArgs ? { } }: inputs.${homeManagerBranch}.lib.homeManagerConfiguration { extraSpecialArgs = specialArgs // { foodogsquaredModulesPath = builtins.toString homeManagerModules; @@ -37,7 +31,8 @@ let home = { sshUser = homeenv.name; user = homeenv.name; - path = inputs.deploy.lib.${homeenv.system}.activate.home-manager homeenv.config; + path = inputs.deploy.lib.${homeenv.system}.activate.home-manager + homeenv.config; }; }; defaultText = lib.literalExpression '' @@ -89,12 +84,11 @@ let }; deploy = lib.mkOption { - type = with lib.types; nullOr (submoduleWith { - specialArgs = { - username = name; - }; - modules = [ deploySettingsType ]; - }); + type = with lib.types; + nullOr (submoduleWith { + specialArgs = { username = name; }; + modules = [ deploySettingsType ]; + }); default = null; description = '' deploy-rs settings to be passed onto the home-manager configuration @@ -107,24 +101,19 @@ let modules = [ "${partsConfig.setups.configDir}/home-manager/${config.configName}" - ( - let - setupConfig = config; - in - { config, lib, ... }: { - nixpkgs.overlays = setupConfig.nixpkgs.overlays; - home.username = lib.mkForce name; - home.homeDirectory = lib.mkForce setupConfig.homeDirectory; - } - ) + (let setupConfig = config; + in { config, lib, ... }: { + nixpkgs.overlays = setupConfig.nixpkgs.overlays; + home.username = lib.mkForce name; + home.homeDirectory = lib.mkForce setupConfig.homeDirectory; + }) ]; nixpkgs.config = cfg.sharedNixpkgsConfig; specialArgs = cfg.sharedSpecialArgs; }; }; -in -{ +in { options.setups.home-manager = { sharedNixpkgsConfig = options.setups.sharedNixpkgsConfig // { description = '' @@ -169,13 +158,14 @@ in }; configs = lib.mkOption { - type = with lib.types; attrsOf (submodule [ - (import ./shared/nix-conf.nix { inherit inputs; }) - (import ./shared/config-options.nix { inherit (config) systems; }) - ./shared/nixpkgs-options.nix - ./shared/special-args-options.nix - configType - ]); + type = with lib.types; + attrsOf (submodule [ + (import ./shared/nix-conf.nix { inherit inputs; }) + (import ./shared/config-options.nix { inherit (config) systems; }) + ./shared/nixpkgs-options.nix + ./shared/special-args-options.nix + configType + ]); default = { }; description = '' An attribute set of metadata for the declarative home-manager setups. @@ -204,171 +194,158 @@ in # Setting up all of the integrations for the wider-scoped environments. options.setups.nixos.configs = lib.mkOption { - type = with lib.types; attrsOf (submodule [ - ./shared/home-manager-users.nix + type = with lib.types; + attrsOf (submodule [ + ./shared/home-manager-users.nix - ({ config, lib, name, ... }: let - inherit (config.home-manager) nixpkgsInstance; - setupConfig = config; + ({ config, lib, name, ... }: + let + inherit (config.home-manager) nixpkgsInstance; + setupConfig = config; - hasHomeManagerUsers = config.home-manager.users != { }; - isNixpkgs = state: hasHomeManagerUsers && nixpkgsInstance == state; - homeManagerUserType = { name, config, lib, ... }: { - options = { - userConfig = lib.mkOption { - type = with lib.types; attrsOf anything; - description = '' - The configuration applied for individual users set in the - wider-scoped environment. - ''; - }; - }; - - config = - let - hmUserConfig = partsConfig.setups.home-manager.configs.${name}; - in - { - userConfig = { - isNormalUser = lib.mkDefault true; - createHome = lib.mkDefault true; - home = lib.mkForce hmUserConfig.homeDirectory; + hasHomeManagerUsers = config.home-manager.users != { }; + isNixpkgs = state: hasHomeManagerUsers && nixpkgsInstance == state; + homeManagerUserType = { name, config, lib, ... }: { + options = { + userConfig = lib.mkOption { + type = with lib.types; attrsOf anything; + description = '' + The configuration applied for individual users set in the + wider-scoped environment. + ''; + }; }; - additionalModules = [ - ({ lib, ... }: { - home.homeDirectory = lib.mkForce hmUserConfig.homeDirectory; - home.username = lib.mkForce name; - }) - ]; + config = let + hmUserConfig = partsConfig.setups.home-manager.configs.${name}; + in { + userConfig = { + isNormalUser = lib.mkDefault true; + createHome = lib.mkDefault true; + home = lib.mkForce hmUserConfig.homeDirectory; + }; + + additionalModules = [ + ({ lib, ... }: { + home.homeDirectory = lib.mkForce hmUserConfig.homeDirectory; + home.username = lib.mkForce name; + }) + ]; + }; }; - }; - in { - options.home-manager = { - users = lib.mkOption { - type = with lib.types; attrsOf (submodule homeManagerUserType); - }; + in { + options.home-manager = { + users = lib.mkOption { + type = with lib.types; attrsOf (submodule homeManagerUserType); + }; - nixpkgsInstance = lib.mkOption { - type = lib.types.enum [ "global" "separate" "none" ]; - default = "global"; - description = '' - Indicates how to manage the nixpkgs instance (or instances) - of the holistic system. This will also dictate how to import - overlays from - {option}`setups.home-manager.configs..overlays`. + nixpkgsInstance = lib.mkOption { + type = lib.types.enum [ "global" "separate" "none" ]; + default = "global"; + description = '' + Indicates how to manage the nixpkgs instance (or instances) + of the holistic system. This will also dictate how to import + overlays from + {option}`setups.home-manager.configs..overlays`. - * `global` enforces to use one nixpkgs instance for all - home-manager users and imports all of the overlays into the - nixpkgs instance of the NixOS system. + * `global` enforces to use one nixpkgs instance for all + home-manager users and imports all of the overlays into the + nixpkgs instance of the NixOS system. - * `separate` enforces the NixOS system to use individual - nixpkgs instance for all home-manager users and imports the - overlays to the nixpkgs instance of the home-manager user. + * `separate` enforces the NixOS system to use individual + nixpkgs instance for all home-manager users and imports the + overlays to the nixpkgs instance of the home-manager user. - * `none` leave the configuration alone and do not import - overlays at all where you have to set them yourself. This is - the best option if you want more control over each individual - NixOS and home-manager configuration. + * `none` leave the configuration alone and do not import + overlays at all where you have to set them yourself. This is + the best option if you want more control over each individual + NixOS and home-manager configuration. - The default value is set to `global` which is the encouraged - practice with this module. - ''; - }; - }; + The default value is set to `global` which is the encouraged + practice with this module. + ''; + }; + }; - # Mapping the declarative home-manager users (if it has one) into NixOS - # users. - config = { - modules = [ - # For declarative NixOS systems, importing home-manager module is - # mandatory. - inputs.${config.home-manager.branch}.nixosModules.home-manager + # Mapping the declarative home-manager users (if it has one) into NixOS + # users. + config = { + modules = [ + # For declarative NixOS systems, importing home-manager module is + # mandatory. + inputs.${config.home-manager.branch}.nixosModules.home-manager - # Set the home-manager-related settings. - ({ lib, ... }: { - home-manager.sharedModules = partsConfig.setups.home-manager.sharedModules; + # Set the home-manager-related settings. + ({ lib, ... }: { + home-manager.sharedModules = + partsConfig.setups.home-manager.sharedModules; - # These are just the recommended options for home-manager that may be - # the default value in the future but this is how most of the NixOS - # setups are already done so... - home-manager.useUserPackages = lib.mkDefault true; - home-manager.useGlobalPkgs = lib.mkDefault true; - }) + # These are just the recommended options for home-manager that may be + # the default value in the future but this is how most of the NixOS + # setups are already done so... + home-manager.useUserPackages = lib.mkDefault true; + home-manager.useGlobalPkgs = lib.mkDefault true; + }) - (lib.mkIf hasHomeManagerUsers ({ lib, pkgs, ... }: { - config = lib.mkMerge [ - { - users.users = - lib.mapAttrs - (name: hmUser: hmUser.userConfig) - setupConfig.home-manager.users; + (lib.mkIf hasHomeManagerUsers ({ lib, pkgs, ... }: { + config = lib.mkMerge [ + { + users.users = + lib.mapAttrs (name: hmUser: hmUser.userConfig) + setupConfig.home-manager.users; - home-manager.users = - lib.mapAttrs - (name: hmUser: { + home-manager.users = lib.mapAttrs (name: hmUser: { imports = partsConfig.setups.home-manager.configs.${name}.modules ++ hmUser.additionalModules; - }) - setupConfig.home-manager.users; - } + }) setupConfig.home-manager.users; + } - (lib.mkIf (isNixpkgs "global") { - home-manager.useGlobalPkgs = lib.mkForce true; + (lib.mkIf (isNixpkgs "global") { + home-manager.useGlobalPkgs = lib.mkForce true; - # Disable all options that are going to be blocked once - # `home-manager.useGlobalPkgs` is used. - home-manager.users = - lib.mapAttrs - (name: _: { + # Disable all options that are going to be blocked once + # `home-manager.useGlobalPkgs` is used. + home-manager.users = lib.mapAttrs (name: _: { nixpkgs.overlays = lib.mkForce null; nixpkgs.config = lib.mkForce null; - }) - setupConfig.home-manager.users; + }) setupConfig.home-manager.users; - # Then apply all of the user overlays into the nixpkgs instance - # of the NixOS system. - nixpkgs.overlays = - let - hmUsersOverlays = - lib.mapAttrsToList - (name: _: - partsConfig.setups.home-manager.configs.${name}.nixpkgs.overlays) + # Then apply all of the user overlays into the nixpkgs instance + # of the NixOS system. + nixpkgs.overlays = let + hmUsersOverlays = lib.mapAttrsToList (name: _: + partsConfig.setups.home-manager.configs.${name}.nixpkgs.overlays) setupConfig.home-manager.users; - overlays = lib.lists.flatten hmUsersOverlays; - in - # Most of the overlays are going to be imported from a - # variable anyways. This should massively reduce the step - # needed for nixpkgs to do its thing. - # - # Though, it becomes unpredictable due to the way how the - # overlay list is constructed. However, this is much more - # preferable than letting a massive list with duplicated - # overlays from different home-manager users to be applied. - # - # Anyways, all I'm saying is that this is a massive hack - # because it isn't correct. - lib.lists.unique overlays; - }) + overlays = lib.lists.flatten hmUsersOverlays; + # Most of the overlays are going to be imported from a + # variable anyways. This should massively reduce the step + # needed for nixpkgs to do its thing. + # + # Though, it becomes unpredictable due to the way how the + # overlay list is constructed. However, this is much more + # preferable than letting a massive list with duplicated + # overlays from different home-manager users to be applied. + # + # Anyways, all I'm saying is that this is a massive hack + # because it isn't correct. + in lib.lists.unique overlays; + }) - (lib.mkIf (isNixpkgs "separate") { - home-manager.useGlobalPkgs = lib.mkForce false; - home-manager.users = - lib.mapAttrs - (name: _: { + (lib.mkIf (isNixpkgs "separate") { + home-manager.useGlobalPkgs = lib.mkForce false; + home-manager.users = lib.mapAttrs (name: _: { nixpkgs.overlays = partsConfig.setups.home-manager.configs.${name}.nixpkgs.overlays; - }) - setupConfig.home-manager.users; - }) + }) setupConfig.home-manager.users; + }) + ]; + })) ]; - })) - ]; - }; - }) - ]); + }; + }) + ]); }; config = lib.mkIf (cfg.configs != { }) { @@ -382,75 +359,53 @@ in ../../home-manager/_private ]; - flake = - let - # A quick data structure we can pass through multiple build pipelines. - pureHomeManagerConfigs = - let - generatePureConfigs = username: metadata: - lib.listToAttrs - (builtins.map - (system: - let - nixpkgs = inputs.${metadata.nixpkgs.branch}; + flake = let + # A quick data structure we can pass through multiple build pipelines. + pureHomeManagerConfigs = let + generatePureConfigs = username: metadata: + lib.listToAttrs (builtins.map (system: + let + nixpkgs = inputs.${metadata.nixpkgs.branch}; - # We won't apply the overlays here since it is set - # modularly. - pkgs = import nixpkgs { - inherit system; - inherit (metadata.nixpkgs) config; - }; - in - lib.nameValuePair system (mkHome { - inherit pkgs system; - inherit (metadata) homeManagerBranch; - extraModules = - cfg.sharedModules - ++ cfg.standaloneConfigModules - ++ metadata.modules; - }) - ) - metadata.systems); - in - lib.mapAttrs generatePureConfigs cfg.configs; - in - { - homeConfigurations = - let - renameSystems = name: system: config: - lib.nameValuePair "${name}-${system}" config; - in - lib.concatMapAttrs - (name: configs: - lib.mapAttrs' (renameSystems name) configs) - pureHomeManagerConfigs; + # We won't apply the overlays here since it is set + # modularly. + pkgs = import nixpkgs { + inherit system; + inherit (metadata.nixpkgs) config; + }; + in lib.nameValuePair system (mkHome { + inherit pkgs system; + inherit (metadata) homeManagerBranch; + extraModules = cfg.sharedModules ++ cfg.standaloneConfigModules + ++ metadata.modules; + })) metadata.systems); + in lib.mapAttrs generatePureConfigs cfg.configs; + in { + homeConfigurations = let + renameSystems = name: system: config: + lib.nameValuePair "${name}-${system}" config; + in lib.concatMapAttrs + (name: configs: lib.mapAttrs' (renameSystems name) configs) + pureHomeManagerConfigs; - deploy.nodes = - let - validConfigs = - lib.filterAttrs - (name: _: cfg.configs.${name}.deploy != null) - pureHomeManagerConfigs; + deploy.nodes = let + validConfigs = + lib.filterAttrs (name: _: cfg.configs.${name}.deploy != null) + pureHomeManagerConfigs; - generateDeployNode = name: system: config: - lib.nameValuePair "home-manager-${name}-${system}" ( - let - deployConfig = cfg.configs.${name}.deploy; - deployConfig' = lib.attrsets.removeAttrs deployConfig [ "profiles" ]; - in - deployConfig' - // { - profiles = - cfg.configs.${name}.deploy.profiles { - inherit name config system; - }; - } - ); - in - lib.concatMapAttrs - (name: configs: - lib.mapAttrs' (generateDeployNode name) configs) - validConfigs; - }; + generateDeployNode = name: system: config: + lib.nameValuePair "home-manager-${name}-${system}" (let + deployConfig = cfg.configs.${name}.deploy; + deployConfig' = + lib.attrsets.removeAttrs deployConfig [ "profiles" ]; + in deployConfig' // { + profiles = cfg.configs.${name}.deploy.profiles { + inherit name config system; + }; + }); + in lib.concatMapAttrs + (name: configs: lib.mapAttrs' (generateDeployNode name) configs) + validConfigs; + }; }; } diff --git a/modules/flake-parts/setups/nixos.nix b/modules/flake-parts/setups/nixos.nix index c384257f..aca5c40c 100644 --- a/modules/flake-parts/setups/nixos.nix +++ b/modules/flake-parts/setups/nixos.nix @@ -10,27 +10,21 @@ let nixosModules = ../../nixos; # A thin wrapper around the NixOS configuration function. - mkHost = { - pkgs, - lib ? pkgs.lib, - system, - extraModules ? [ ], - specialArgs ? { }, - }: + mkHost = + { pkgs, lib ? pkgs.lib, system, extraModules ? [ ], specialArgs ? { }, }: let # Evaluating the system ourselves (which is trivial) instead of relying # on nixpkgs.lib.nixosSystem flake output. nixosSystem = args: import "${pkgs.path}/nixos/lib/eval-config.nix" args; - in - (lib.makeOverridable nixosSystem) { + in (lib.makeOverridable nixosSystem) { inherit pkgs; specialArgs = specialArgs // { - foodogsquaredUtils = import ../../../lib/utils/nixos.nix { inherit lib; }; + foodogsquaredUtils = + import ../../../lib/utils/nixos.nix { inherit lib; }; foodogsquaredModulesPath = builtins.toString nixosModules; }; - modules = extraModules ++ [{ - nixpkgs.hostPlatform = lib.mkForce system; - }]; + modules = extraModules + ++ [{ nixpkgs.hostPlatform = lib.mkForce system; }]; # Since we're setting it through nixpkgs.hostPlatform, we'll have to pass # this as null. @@ -38,37 +32,25 @@ let }; # The nixos-generators modules set as well as our custom-made ones. - nixosGeneratorsModulesSet = - let - importNixosGeneratorModule = (_: modulePath: { - imports = [ - modulePath - "${inputs.nixos-generators}/format-module.nix" - ]; - }); + nixosGeneratorsModulesSet = let + importNixosGeneratorModule = (_: modulePath: { + imports = [ modulePath "${inputs.nixos-generators}/format-module.nix" ]; + }); - customFormats = lib.mapAttrs importNixosGeneratorModule { - install-iso-graphical = ../../nixos-generators/install-iso-graphical.nix; - }; - in - inputs.nixos-generators.nixosModules // customFormats; + customFormats = lib.mapAttrs importNixosGeneratorModule { + install-iso-graphical = ../../nixos-generators/install-iso-graphical.nix; + }; + in inputs.nixos-generators.nixosModules // customFormats; # A very very thin wrapper around `mkHost` to build with the given format. - mkImage = { - pkgs, - system, - extraModules ? [ ], - format ? "iso", - }: + mkImage = { pkgs, system, extraModules ? [ ], format ? "iso", }: let - extraModules' = - extraModules ++ [ nixosGeneratorsModulesSet.${format} ]; + extraModules' = extraModules ++ [ nixosGeneratorsModulesSet.${format} ]; image = mkHost { inherit pkgs system; extraModules = extraModules'; }; - in - image.config.system.build.${image.config.formatAttr}; + in image.config.system.build.${image.config.formatAttr}; deployNodeType = { config, lib, ... }: { freeformType = with lib.types; attrsOf anything; @@ -111,74 +93,73 @@ let }; }; - configType = { options, config, name, lib, ... }: let - setupConfig = config; - in { - options = { - formats = lib.mkOption { - type = with lib.types; nullOr (listOf str); - default = [ "iso" ]; - description = '' - The image formats to be generated from nixos-generators. When given - as `null`, it is listed as part of `nixosConfigurations` and excluded - from `images` flake output which is often the case for desktop NixOS - systems. - ''; - }; + configType = { options, config, name, lib, ... }: + let setupConfig = config; + in { + options = { + formats = lib.mkOption { + type = with lib.types; nullOr (listOf str); + default = [ "iso" ]; + description = '' + The image formats to be generated from nixos-generators. When given + as `null`, it is listed as part of `nixosConfigurations` and excluded + from `images` flake output which is often the case for desktop NixOS + systems. + ''; + }; - hostname = lib.mkOption { - type = lib.types.nonEmptyStr; - default = name; - example = "MyWhatNow"; - description = "The hostname of the NixOS configuration."; - }; + hostname = lib.mkOption { + type = lib.types.nonEmptyStr; + default = name; + example = "MyWhatNow"; + description = "The hostname of the NixOS configuration."; + }; - domain = lib.mkOption { - type = with lib.types; nullOr nonEmptyStr; - default = null; - example = "work.example.com"; - description = "The domain of the NixOS system."; - }; + domain = lib.mkOption { + type = with lib.types; nullOr nonEmptyStr; + default = null; + example = "work.example.com"; + description = "The domain of the NixOS system."; + }; - deploy = lib.mkOption { - type = with lib.types; nullOr (submodule deployNodeType); - default = null; - description = '' - deploy-rs node settings for the resulting NixOS configuration. When - this attribute is given with a non-null value, it will be included in - `nixosConfigurations` even if - {option}`setups.nixos.configs..formats` is set. - ''; - example = { - hostname = "work1.example.com"; - fastConnection = true; - autoRollback = true; - magicRollback = true; - remoteBuild = true; + deploy = lib.mkOption { + type = with lib.types; nullOr (submodule deployNodeType); + default = null; + description = '' + deploy-rs node settings for the resulting NixOS configuration. When + this attribute is given with a non-null value, it will be included in + `nixosConfigurations` even if + {option}`setups.nixos.configs..formats` is set. + ''; + example = { + hostname = "work1.example.com"; + fastConnection = true; + autoRollback = true; + magicRollback = true; + remoteBuild = true; + }; + }; + + shouldBePartOfNixOSConfigurations = lib.mkOption { + type = lib.types.bool; + default = lib.isAttrs config.deploy || config.formats == null; + example = true; + description = '' + Indicates whether the declarative NixOS setup should be included as + part of the `nixosConfigurations` flake output. + ''; }; }; - shouldBePartOfNixOSConfigurations = lib.mkOption { - type = lib.types.bool; - default = lib.isAttrs config.deploy || config.formats == null; - example = true; - description = '' - Indicates whether the declarative NixOS setup should be included as - part of the `nixosConfigurations` flake output. - ''; - }; - }; + config.nixpkgs.config = cfg.sharedNixpkgsConfig; + config.specialArgs = cfg.sharedSpecialArgs; - config.nixpkgs.config = cfg.sharedNixpkgsConfig; - config.specialArgs = cfg.sharedSpecialArgs; + config.modules = [ + # Bring in the required modules. + "${partsConfig.setups.configDir}/nixos/${config.configName}" - config.modules = [ - # Bring in the required modules. - "${partsConfig.setups.configDir}/nixos/${config.configName}" - - # Setting up the typical configuration. - ( - { config, lib, ... }: { + # Setting up the typical configuration. + ({ config, lib, ... }: { config = lib.mkMerge [ { nixpkgs.overlays = setupConfig.nixpkgs.overlays; @@ -189,12 +170,10 @@ let networking.domain = lib.mkDefault setupConfig.domain; }) ]; - } - ) - ]; - }; -in -{ + }) + ]; + }; +in { options.setups.nixos = { sharedNixpkgsConfig = options.setups.sharedNixpkgsConfig // { description = '' @@ -226,13 +205,14 @@ in }; configs = lib.mkOption { - type = with lib.types; attrsOf (submodule [ - (import ./shared/nix-conf.nix { inherit inputs; }) - (import ./shared/config-options.nix { inherit (config) systems; }) - ./shared/nixpkgs-options.nix - ./shared/special-args-options.nix - configType - ]); + type = with lib.types; + attrsOf (submodule [ + (import ./shared/nix-conf.nix { inherit inputs; }) + (import ./shared/config-options.nix { inherit (config) systems; }) + ./shared/nixpkgs-options.nix + ./shared/special-args-options.nix + configType + ]); default = { }; description = '' An attribute set of metadata for the declarative NixOS setups. This @@ -303,105 +283,77 @@ in ../../nixos/_private ]; - flake = - let - # A quick data structure we can pass through multiple build pipelines. - pureNixosConfigs = - let - validConfigs = - lib.filterAttrs (_: v: v.shouldBePartOfNixOSConfigurations) cfg.configs; + flake = let + # A quick data structure we can pass through multiple build pipelines. + pureNixosConfigs = let + validConfigs = + lib.filterAttrs (_: v: v.shouldBePartOfNixOSConfigurations) + cfg.configs; - generatePureConfigs = hostname: metadata: - lib.listToAttrs - (builtins.map - (system: - let - nixpkgs = inputs.${metadata.nixpkgs.branch}; + generatePureConfigs = hostname: metadata: + lib.listToAttrs (builtins.map (system: + let + nixpkgs = inputs.${metadata.nixpkgs.branch}; - # We won't apply the overlays here since it is set - # modularly. - pkgs = import nixpkgs { - inherit system; - inherit (metadata.nixpkgs) config; - }; - in - lib.nameValuePair system (mkHost { - inherit pkgs system; - inherit (metadata) specialArgs; - extraModules = cfg.sharedModules ++ metadata.modules; - }) - ) - metadata.systems); - in - lib.mapAttrs generatePureConfigs validConfigs; - in - { - nixosConfigurations = - let - renameSystem = name: system: config: - lib.nameValuePair "${name}-${system}" config; - in - lib.concatMapAttrs - (name: configs: - lib.mapAttrs' (renameSystem name) configs) - pureNixosConfigs; + # We won't apply the overlays here since it is set + # modularly. + pkgs = import nixpkgs { + inherit system; + inherit (metadata.nixpkgs) config; + }; + in lib.nameValuePair system (mkHost { + inherit pkgs system; + inherit (metadata) specialArgs; + extraModules = cfg.sharedModules ++ metadata.modules; + })) metadata.systems); + in lib.mapAttrs generatePureConfigs validConfigs; + in { + nixosConfigurations = let + renameSystem = name: system: config: + lib.nameValuePair "${name}-${system}" config; + in lib.concatMapAttrs + (name: configs: lib.mapAttrs' (renameSystem name) configs) + pureNixosConfigs; - deploy.nodes = - let - validConfigs = - lib.filterAttrs - (name: _: cfg.configs.${name}.deploy != null) - pureNixosConfigs; + deploy.nodes = let + validConfigs = + lib.filterAttrs (name: _: cfg.configs.${name}.deploy != null) + pureNixosConfigs; - generateDeployNode = name: system: config: - lib.nameValuePair "nixos-${name}-${system}" - ( - let - deployConfig = cfg.configs.${name}.deploy; - in - deployConfig - // { - profiles = - cfg.configs.${name}.deploy.profiles { - inherit name config system; - }; - } - ); - in - lib.concatMapAttrs - (name: configs: - lib.mapAttrs' (generateDeployNode name) configs) - validConfigs; - }; + generateDeployNode = name: system: config: + lib.nameValuePair "nixos-${name}-${system}" + (let deployConfig = cfg.configs.${name}.deploy; + in deployConfig // { + profiles = cfg.configs.${name}.deploy.profiles { + inherit name config system; + }; + }); + in lib.concatMapAttrs + (name: configs: lib.mapAttrs' (generateDeployNode name) configs) + validConfigs; + }; perSystem = { system, lib, ... }: { - images = - let - validImages = lib.filterAttrs - (host: metadata: - metadata.formats != null && (lib.elem system metadata.systems)) - cfg.configs; + images = let + validImages = lib.filterAttrs (host: metadata: + metadata.formats != null && (lib.elem system metadata.systems)) + cfg.configs; - generateImages = name: metadata: - let - buildImage = format: - lib.nameValuePair - "${name}-${format}" - (mkImage { - inherit format system; - pkgs = import inputs.${metadata.nixpkgs.branch} { - inherit system; - inherit (metadata.nixpkgs) config; - }; - extraModules = cfg.sharedModules ++ metadata.modules; - }); + generateImages = name: metadata: + let + buildImage = format: + lib.nameValuePair "${name}-${format}" (mkImage { + inherit format system; + pkgs = import inputs.${metadata.nixpkgs.branch} { + inherit system; + inherit (metadata.nixpkgs) config; + }; + extraModules = cfg.sharedModules ++ metadata.modules; + }); - images = - builtins.map buildImage metadata.formats; - in - lib.listToAttrs images; - in - lib.concatMapAttrs generateImages validImages; + images = builtins.map buildImage metadata.formats; + in lib.listToAttrs images; + in lib.concatMapAttrs generateImages validImages; }; }; } diff --git a/modules/flake-parts/setups/nixvim.nix b/modules/flake-parts/setups/nixvim.nix index a705213b..37490313 100644 --- a/modules/flake-parts/setups/nixvim.nix +++ b/modules/flake-parts/setups/nixvim.nix @@ -1,31 +1,20 @@ # Declarative NixVim configurations because everything under the Nix ecosystem # must be so declarative so we're setting up declarative ways of declaring # those accursed setups to be exported in this flake. -{ inputs -, lib -, config -, options +{ inputs, lib, config, options -, ... -}: +, ... }: let partsConfig = config; cfg = config.setups.nixvim; nixvimModules = ../../nixvim; - mkNixvimConfig = { - system, - pkgs, - nixvimBranch ? "nixvim", - modules ? [ ], - specialArgs ? { }, - }: + mkNixvimConfig = { system, pkgs, nixvimBranch ? "nixvim", modules ? [ ] + , specialArgs ? { }, }: inputs.${nixvimBranch}.legacyPackages.${system}.makeNixvimWithModule { inherit pkgs; - module = { - imports = modules; - }; + module = { imports = modules; }; extraSpecialArgs = specialArgs // { foodogsquaredModulesPath = builtins.toString nixvimModules; }; @@ -35,12 +24,13 @@ let type = with lib.types; listOf deferredModule; default = [ ]; }; - modulesOption' = configEnv: modulesOption // { - description = '' - A list of NixVim modules to be applied across all NixVim configurations - when imported as part of ${configEnv}. - ''; - }; + modulesOption' = configEnv: + modulesOption // { + description = '' + A list of NixVim modules to be applied across all NixVim configurations + when imported as part of ${configEnv}. + ''; + }; componentType = { lib, config, ... }: { imports = [ @@ -83,9 +73,7 @@ let }; }; - config = { - nixpkgs.config = cfg.sharedNixpkgsConfig; - }; + config = { nixpkgs.config = cfg.sharedNixpkgsConfig; }; }; configType = { name, lib, config, ... }: { @@ -97,17 +85,26 @@ let built against. ''; example = [ - { nixpkgsBranch = "nixos-unstable"; nixvimBranch = "nixvim-unstable"; } - { nixpkgsBranch = "nixos-stable"; nixvimBranch = "nixvim-stable"; } - { nixpkgsBranch = "nixos-stable"; nixvimBranch = "nixvim-stable"; neovimPackage = pkgs: pkgs.neovim-nightly; } + { + nixpkgsBranch = "nixos-unstable"; + nixvimBranch = "nixvim-unstable"; + } + { + nixpkgsBranch = "nixos-stable"; + nixvimBranch = "nixvim-stable"; + } + { + nixpkgsBranch = "nixos-stable"; + nixvimBranch = "nixvim-stable"; + neovimPackage = pkgs: pkgs.neovim-nightly; + } ]; }; }; config = { - modules = [ - "${partsConfig.setups.configDir}/nixvim/${config.configName}" - ]; + modules = + [ "${partsConfig.setups.configDir}/nixvim/${config.configName}" ]; specialArgs = cfg.sharedSpecialArgs; }; @@ -165,15 +162,15 @@ let ]; }; }; -in -{ +in { options.setups.nixvim = { configs = lib.mkOption { - type = with lib.types; attrsOf (submodule [ - (import ./shared/config-options.nix { inherit (config) systems; }) - ./shared/special-args-options.nix - configType - ]); + type = with lib.types; + attrsOf (submodule [ + (import ./shared/config-options.nix { inherit (config) systems; }) + ./shared/special-args-options.nix + configType + ]); default = { }; description = '' A set of NixVim configurations to be integrated into the declarative @@ -207,25 +204,25 @@ in }; options.setups.nixos.configs = lib.mkOption { - type = with lib.types; attrsOf (submodule [ - nixvimIntegrationModule - ({ config, lib, ... }: { - config.modules = [ - inputs.${config.nixvim.branch}.nixosModules.nixvim - ]; - }) - ]); + type = with lib.types; + attrsOf (submodule [ + nixvimIntegrationModule + ({ config, lib, ... }: { + config.modules = + [ inputs.${config.nixvim.branch}.nixosModules.nixvim ]; + }) + ]); }; options.setups.home-manager.configs = lib.mkOption { - type = with lib.types; attrsOf (submodule [ - nixvimIntegrationModule - ({ config, lib, ... }: { - config.modules = [ - inputs.${config.nixvim.branch}.homeManagerModules.nixvim - ]; - }) - ]); + type = with lib.types; + attrsOf (submodule [ + nixvimIntegrationModule + ({ config, lib, ... }: { + config.modules = + [ inputs.${config.nixvim.branch}.homeManagerModules.nixvim ]; + }) + ]); }; config = lib.mkIf (cfg.configs != { }) { @@ -239,56 +236,42 @@ in ]; perSystem = { system, config, lib, ... }: - ( - let - validConfigs = lib.filterAttrs - (_: metadata: lib.elem system metadata.systems) - cfg.configs; + (let + validConfigs = + lib.filterAttrs (_: metadata: lib.elem system metadata.systems) + cfg.configs; - nixvimConfigurations = + nixvimConfigurations = let + generateNixvimConfigs = name: metadata: let - generateNixvimConfigs = name: metadata: + mkNixvimConfig' = component: let - mkNixvimConfig' = component: - let - pkgs = import inputs.${component.nixpkgsBranch} { - inherit (component.nixpkgs) config overlays; - inherit system; - }; - neovimPackage = component.neovimPackage pkgs; - in - lib.nameValuePair - "${name}-${component.nixpkgsBranch}-${neovimPackage.pname}" - (mkNixvimConfig { - inherit system pkgs; - inherit (component) nixvimBranch; - modules = - cfg.sharedModules - ++ cfg.standaloneConfigModules - ++ metadata.modules - ++ [{ package = neovimPackage; }]; - }); - nixvimConfigs = builtins.map mkNixvimConfig' metadata.components; - in - lib.listToAttrs nixvimConfigs; - in - lib.concatMapAttrs generateNixvimConfigs validConfigs; - in - { - # We'll reuse these. - inherit nixvimConfigurations; + pkgs = import inputs.${component.nixpkgsBranch} { + inherit (component.nixpkgs) config overlays; + inherit system; + }; + neovimPackage = component.neovimPackage pkgs; + in lib.nameValuePair + "${name}-${component.nixpkgsBranch}-${neovimPackage.pname}" + (mkNixvimConfig { + inherit system pkgs; + inherit (component) nixvimBranch; + modules = cfg.sharedModules ++ cfg.standaloneConfigModules + ++ metadata.modules ++ [{ package = neovimPackage; }]; + }); + nixvimConfigs = builtins.map mkNixvimConfig' metadata.components; + in lib.listToAttrs nixvimConfigs; + in lib.concatMapAttrs generateNixvimConfigs validConfigs; + in { + # We'll reuse these. + inherit nixvimConfigurations; - checks = - lib.mapAttrs' - (name: nvim: - lib.nameValuePair - "nixvim-check-${name}" - (inputs.nixvim.lib.${system}.check.mkTestDerivationFromNvim { - inherit nvim; - name = "${name} configuration"; - })) - nixvimConfigurations; - } - ); + checks = lib.mapAttrs' (name: nvim: + lib.nameValuePair "nixvim-check-${name}" + (inputs.nixvim.lib.${system}.check.mkTestDerivationFromNvim { + inherit nvim; + name = "${name} configuration"; + })) nixvimConfigurations; + }); }; } diff --git a/modules/flake-parts/setups/shared/deploy-node-type.nix b/modules/flake-parts/setups/shared/deploy-node-type.nix index c086626a..f98efc1c 100644 --- a/modules/flake-parts/setups/shared/deploy-node-type.nix +++ b/modules/flake-parts/setups/shared/deploy-node-type.nix @@ -3,16 +3,15 @@ # deploy-rs-related option, not in the top-level `configs` option. { lib, ... }: { options = { - fastConnection = - lib.mkEnableOption "deploy-rs to assume the target machine is considered fast"; - autoRollback = - lib.mkEnableOption "deploy-rs auto-rollback feature" // { - default = true; - }; - magicRollback = - lib.mkEnableOption "deploy-rs magic rollback feature" // { - default = true; - }; - remoteBuild = lib.mkEnableOption "pass the build process to the remote machine"; + fastConnection = lib.mkEnableOption + "deploy-rs to assume the target machine is considered fast"; + autoRollback = lib.mkEnableOption "deploy-rs auto-rollback feature" // { + default = true; + }; + magicRollback = lib.mkEnableOption "deploy-rs magic rollback feature" // { + default = true; + }; + remoteBuild = + lib.mkEnableOption "pass the build process to the remote machine"; }; } diff --git a/modules/flake-parts/setups/shared/home-manager-users.nix b/modules/flake-parts/setups/shared/home-manager-users.nix index 2d634015..b88233c9 100644 --- a/modules/flake-parts/setups/shared/home-manager-users.nix +++ b/modules/flake-parts/setups/shared/home-manager-users.nix @@ -14,14 +14,16 @@ let }; }; }; -in -{ +in { # This option is for the wider-scoped environment to be easily compatible # with the home-manager flake-parts module where it also shares the Nix # configuration submodule. Without this option, it would not work (or we # could just rename the options from the home-manager module). imports = [ - (lib.mkAliasOptionModule [ "homeManagerBranch" ] [ "home-manager" "branch" ]) + (lib.mkAliasOptionModule [ "homeManagerBranch" ] [ + "home-manager" + "branch" + ]) ]; options.home-manager = { @@ -61,12 +63,7 @@ in }; }; - plover.userConfig = { - extraGroups = [ - "adm" - "wheel" - ]; - }; + plover.userConfig = { extraGroups = [ "adm" "wheel" ]; }; }; }; }; diff --git a/modules/flake-parts/setups/shared/nix-conf.nix b/modules/flake-parts/setups/shared/nix-conf.nix index 7af0529a..e3df98a2 100644 --- a/modules/flake-parts/setups/shared/nix-conf.nix +++ b/modules/flake-parts/setups/shared/nix-conf.nix @@ -8,33 +8,24 @@ let home-manager = inputs.${config.homeManagerBranch}; }; - flakeInputName = name: - if name == "self" then "config" else name; + flakeInputName = name: if name == "self" then "config" else name; nixChannels = - lib.mapAttrsToList - (name: source: "${flakeInputName name}=${source}") - inputs' - ++ [ - "/nix/var/nix/profiles/per-user/root/channels" - ]; -in -{ - config.modules = [( - { lib, ... }: { + lib.mapAttrsToList (name: source: "${flakeInputName name}=${source}") + inputs' ++ [ "/nix/var/nix/profiles/per-user/root/channels" ]; +in { + config.modules = [ + ({ lib, ... }: { # I want to capture the usual flakes to its exact version so we're # making them available to our system. This will also prevent the # annoying downloads since it always get the latest revision. - nix.registry = - lib.mapAttrs' - (name: flake: - lib.nameValuePair (flakeInputName name) { inherit flake; }) - inputs'; + nix.registry = lib.mapAttrs' (name: flake: + lib.nameValuePair (flakeInputName name) { inherit flake; }) inputs'; nix.settings.nix-path = nixChannels; # It doesn't work on the traditional tools like nix-shell so ehhh... nix.nixPath = nixChannels; - } - )]; + }) + ]; } diff --git a/modules/flake-parts/setups/shared/nixpkgs-options.nix b/modules/flake-parts/setups/shared/nixpkgs-options.nix index b8dde580..715ce189 100644 --- a/modules/flake-parts/setups/shared/nixpkgs-options.nix +++ b/modules/flake-parts/setups/shared/nixpkgs-options.nix @@ -3,9 +3,8 @@ { # A compatibility option while the newer iteration of configuring nixpkgs # inside our internal flake-parts module is in progress. - imports = [ - (lib.mkAliasOptionModule [ "nixpkgsBranch" ] [ "nixpkgs" "branch" ]) - ]; + imports = + [ (lib.mkAliasOptionModule [ "nixpkgsBranch" ] [ "nixpkgs" "branch" ]) ]; options.nixpkgs = { branch = lib.mkOption { @@ -31,9 +30,7 @@ environment. ''; default = { }; - example = { - allowUnfree = true; - }; + example = { allowUnfree = true; }; }; overlays = lib.mkOption { diff --git a/modules/flake-parts/setups/wrapper-manager.nix b/modules/flake-parts/setups/wrapper-manager.nix index ef7a7bd7..72a41864 100644 --- a/modules/flake-parts/setups/wrapper-manager.nix +++ b/modules/flake-parts/setups/wrapper-manager.nix @@ -4,18 +4,9 @@ let partsConfig = config; cfg = config.setups.wrapper-manager; - mkWrapperManagerPackage = { - pkgs, - src, - modules ? [ ], - specialArgs ? { }, - }: - let - wrapperManagerEntrypoint = import src { }; - in - wrapperManagerEntrypoint.lib.build { - inherit pkgs modules specialArgs; - }; + mkWrapperManagerPackage = { pkgs, src, modules ? [ ], specialArgs ? { }, }: + let wrapperManagerEntrypoint = import src { }; + in wrapperManagerEntrypoint.lib.build { inherit pkgs modules specialArgs; }; wrapperManagerIntegrationModule = { name, config, lib, ... }: { options.wrapper-manager = { @@ -38,16 +29,17 @@ let }; packages = lib.mkOption { - type = with lib.types; attrsOf (submodule { - options.additionalModules = lib.mkOption { - type = with lib.types; listOf deferredModule; - description = '' - Additional wrapper-manager modules to be included into the given - declarative wrapper-manager configuration. - ''; - default = [ ]; - }; - }); + type = with lib.types; + attrsOf (submodule { + options.additionalModules = lib.mkOption { + type = with lib.types; listOf deferredModule; + description = '' + Additional wrapper-manager modules to be included into the given + declarative wrapper-manager configuration. + ''; + default = [ ]; + }; + }); default = { }; description = '' Include declared wrapper-manager packages into the wider environment. @@ -58,15 +50,13 @@ let config = lib.mkIf (config.wrapper-manager.packages != { }) { modules = [ ({ lib, ... }: { - wrapper-manager.sharedModules = - cfg.sharedModules ++ config.wrapper-manager.additionalModules; + wrapper-manager.sharedModules = cfg.sharedModules + ++ config.wrapper-manager.additionalModules; - wrapper-manager.packages = - lib.mapAttrs (name: wmPackage: { - imports = - partsConfig.setups.wrapper-manager.configs.${name}.modules - ++ wmPackage.additionalModules; - }) config.wrapper-manager.packages; + wrapper-manager.packages = lib.mapAttrs (name: wmPackage: { + imports = partsConfig.setups.wrapper-manager.configs.${name}.modules + ++ wmPackage.additionalModules; + }) config.wrapper-manager.packages; }) ]; }; @@ -90,8 +80,7 @@ let ]; }; }; -in -{ +in { options.setups.wrapper-manager = { sharedNixpkgsConfig = options.setups.sharedNixpkgsConfig // { description = '' @@ -101,11 +90,12 @@ in }; configs = lib.mkOption { - type = with lib.types; attrsOf (submodule [ - (import ./shared/config-options.nix { inherit (config) systems; }) - ./shared/nixpkgs-options.nix - wrapperManagerConfigModule - ]); + type = with lib.types; + attrsOf (submodule [ + (import ./shared/config-options.nix { inherit (config) systems; }) + ./shared/nixpkgs-options.nix + wrapperManagerConfigModule + ]); default = { }; description = '' Declarative wrapper-manager packages to be exported into the flake. @@ -141,62 +131,56 @@ in # Integrations with the composable environments such as NixOS and home-manager. options.setups.nixos.configs = lib.mkOption { - type = with lib.types; attrsOf (submodule [ - wrapperManagerIntegrationModule - ({ config, lib, ... }: { - config = lib.mkIf (config.wrapper-manager.packages != { }) { - modules = [ - (import config.wrapper-manager.src { }).nixosModules.default - ]; - }; - }) - ]); + type = with lib.types; + attrsOf (submodule [ + wrapperManagerIntegrationModule + ({ config, lib, ... }: { + config = lib.mkIf (config.wrapper-manager.packages != { }) { + modules = + [ (import config.wrapper-manager.src { }).nixosModules.default ]; + }; + }) + ]); }; options.setups.home-manager.configs = lib.mkOption { - type = with lib.types; attrsOf (submodule [ - wrapperManagerIntegrationModule - ({ config, lib, ... }: { - config = lib.mkIf (config.wrapper-manager.packages != { }) { - modules = [ - (import config.wrapper-manager.src { }).homeModules.default - ]; - }; - }) - ]); + type = with lib.types; + attrsOf (submodule [ + wrapperManagerIntegrationModule + ({ config, lib, ... }: { + config = lib.mkIf (config.wrapper-manager.packages != { }) { + modules = + [ (import config.wrapper-manager.src { }).homeModules.default ]; + }; + }) + ]); }; config = lib.mkIf (cfg.configs != { }) { - setups.wrapper-manager.sharedNixpkgsConfig = config.setups.sharedNixpkgsConfig; + setups.wrapper-manager.sharedNixpkgsConfig = + config.setups.sharedNixpkgsConfig; - setups.wrapper-manager.sharedModules = [ - ../../wrapper-manager - ../../wrapper-manager/_private - ]; + setups.wrapper-manager.sharedModules = + [ ../../wrapper-manager ../../wrapper-manager/_private ]; - perSystem = { system, config, lib, ... }: let - validWrapperManagerConfigs = - lib.filterAttrs (_: metadata: lib.elem system metadata.systems) cfg.configs; - in { - wrapperManagerPackages = - lib.mapAttrs - (name: metadata: - let - pkgs = import inputs.${metadata.nixpkgs.branch} { - inherit (metadata.nixpkgs) config; - inherit system; - }; - in - mkWrapperManagerPackage { - inherit pkgs; - inherit (metadata.wrapper-manager) src; - modules = - cfg.sharedModules - ++ cfg.standaloneModules - ++ metadata.modules; - } - ) - validWrapperManagerConfigs; - }; + perSystem = { system, config, lib, ... }: + let + validWrapperManagerConfigs = + lib.filterAttrs (_: metadata: lib.elem system metadata.systems) + cfg.configs; + in { + wrapperManagerPackages = lib.mapAttrs (name: metadata: + let + pkgs = import inputs.${metadata.nixpkgs.branch} { + inherit (metadata.nixpkgs) config; + inherit system; + }; + in mkWrapperManagerPackage { + inherit pkgs; + inherit (metadata.wrapper-manager) src; + modules = cfg.sharedModules ++ cfg.standaloneModules + ++ metadata.modules; + }) validWrapperManagerConfigs; + }; }; } diff --git a/modules/flake-parts/wrapper-manager-packages.nix b/modules/flake-parts/wrapper-manager-packages.nix index 153fee2c..e023b46f 100644 --- a/modules/flake-parts/wrapper-manager-packages.nix +++ b/modules/flake-parts/wrapper-manager-packages.nix @@ -3,10 +3,8 @@ # `wrapperManagerPackages` containing the derivations that can be run or build. { config, lib, flake-parts-lib, ... }: -let - inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption; -in -{ +let inherit (flake-parts-lib) mkSubmoduleOptions mkPerSystemOption; +in { options = { flake = mkSubmoduleOptions { wrapperManagerPackages = lib.mkOption { @@ -32,13 +30,9 @@ in }; config = { - flake.wrapperManagerPackages = - lib.mapAttrs - (k: v: v.wrapperManagerPackages) - (lib.filterAttrs - (k: v: v.wrapperManagerPackages != { }) - config.allSystems - ); + flake.wrapperManagerPackages = lib.mapAttrs (k: v: v.wrapperManagerPackages) + (lib.filterAttrs (k: v: v.wrapperManagerPackages != { }) + config.allSystems); perInput = system: flake: lib.optionalAttrs (flake ? wrapperManagerPackages.${system}) { diff --git a/modules/home-manager/_private/extra-arguments.nix b/modules/home-manager/_private/extra-arguments.nix index c9918dcc..a6ae42d8 100644 --- a/modules/home-manager/_private/extra-arguments.nix +++ b/modules/home-manager/_private/extra-arguments.nix @@ -2,16 +2,23 @@ # environment. { pkgs, lib, options, ... }@attrs: -let - foodogsquaredLib = import ../../../lib { inherit pkgs; }; -in -{ - _module.args.foodogsquaredLib = - foodogsquaredLib.extend (final: prev: { - home-manager = import ../../../lib/env-specific/home-manager.nix { inherit pkgs lib; self = final; }; - } // lib.optionalAttrs (options?sops) { - sops-nix = import ../../../lib/env-specific/sops.nix { inherit pkgs lib; self = final; }; - } // lib.optionalAttrs (attrs?nixosConfig) { - nixos = import ../../../lib/env-specific/nixos.nix { inherit pkgs lib; self = final; }; +let foodogsquaredLib = import ../../../lib { inherit pkgs; }; +in { + _module.args.foodogsquaredLib = foodogsquaredLib.extend (final: prev: + { + home-manager = import ../../../lib/env-specific/home-manager.nix { + inherit pkgs lib; + self = final; + }; + } // lib.optionalAttrs (options ? sops) { + sops-nix = import ../../../lib/env-specific/sops.nix { + inherit pkgs lib; + self = final; + }; + } // lib.optionalAttrs (attrs ? nixosConfig) { + nixos = import ../../../lib/env-specific/nixos.nix { + inherit pkgs lib; + self = final; + }; }); } diff --git a/modules/home-manager/_private/state/default.nix b/modules/home-manager/_private/state/default.nix index 2563921f..e5e1f893 100644 --- a/modules/home-manager/_private/state/default.nix +++ b/modules/home-manager/_private/state/default.nix @@ -1,11 +1,7 @@ { lib, ... }: { - imports = [ - ./ports.nix - ./paths.nix - ./packages.nix - ]; + imports = [ ./ports.nix ./paths.nix ./packages.nix ]; options.state = lib.mkOption { type = lib.types.submodule { @@ -19,11 +15,7 @@ ''; example = { sampleValue = 10; - paths.ignoreDirectories = [ - ".git" - "node_modules" - ".direnv" - ]; + paths.ignoreDirectories = [ ".git" "node_modules" ".direnv" ]; }; }; } diff --git a/modules/home-manager/_private/state/packages.nix b/modules/home-manager/_private/state/packages.nix index c0c86ca2..c33325cb 100644 --- a/modules/home-manager/_private/state/packages.nix +++ b/modules/home-manager/_private/state/packages.nix @@ -1,29 +1,26 @@ { lib, ... }: { - options.state = - let - packagesSubmodule = { lib, ... }: { - options = { - packages = lib.mkOption { - type = with lib.types; attrsOf package; - default = { }; - description = '' - Source of truth containing a set of packages. Useful for options - where there are no specific options for a package or as a unified - source of truth for different module options requiring a package. - ''; - example = lib.literalExpression '' - { - diff = pkgs.vimdiff; - pager = pkgs.bat; - editor = pkgs.neovim; - } - ''; - }; + options.state = let + packagesSubmodule = { lib, ... }: { + options = { + packages = lib.mkOption { + type = with lib.types; attrsOf package; + default = { }; + description = '' + Source of truth containing a set of packages. Useful for options + where there are no specific options for a package or as a unified + source of truth for different module options requiring a package. + ''; + example = lib.literalExpression '' + { + diff = pkgs.vimdiff; + pager = pkgs.bat; + editor = pkgs.neovim; + } + ''; }; }; - in lib.mkOption { - type = lib.types.submodule packagesSubmodule; - }; + }; + in lib.mkOption { type = lib.types.submodule packagesSubmodule; }; } diff --git a/modules/home-manager/_private/state/paths.nix b/modules/home-manager/_private/state/paths.nix index 9979b4f3..c8a0af0e 100644 --- a/modules/home-manager/_private/state/paths.nix +++ b/modules/home-manager/_private/state/paths.nix @@ -1,28 +1,25 @@ { lib, ... }: { - options.state = - let - pathsSubmodule = { lib, ... }: { - options = { - paths = lib.mkOption { - type = with lib.types; attrsOf (either path (listOf str)); - default = { }; - description = '' - Set of paths to hold as a single source of truth for path-related - settings throughout the whole home environment. - ''; - example = lib.literalExpression '' - { - cacheDir = config.xdg.cacheHome; - ignoreDirectories = [ "''${config.home.homeDirectory}/Nodes" ]; - ignorePaths = [ ".gitignore" "node_modules" "result" ]; - } - ''; - }; + options.state = let + pathsSubmodule = { lib, ... }: { + options = { + paths = lib.mkOption { + type = with lib.types; attrsOf (either path (listOf str)); + default = { }; + description = '' + Set of paths to hold as a single source of truth for path-related + settings throughout the whole home environment. + ''; + example = lib.literalExpression '' + { + cacheDir = config.xdg.cacheHome; + ignoreDirectories = [ "''${config.home.homeDirectory}/Nodes" ]; + ignorePaths = [ ".gitignore" "node_modules" "result" ]; + } + ''; }; }; - in lib.mkOption { - type = lib.types.submodule pathsSubmodule; - }; + }; + in lib.mkOption { type = lib.types.submodule pathsSubmodule; }; } diff --git a/modules/home-manager/_private/state/ports.nix b/modules/home-manager/_private/state/ports.nix index f5ea0a0b..099b8b14 100644 --- a/modules/home-manager/_private/state/ports.nix +++ b/modules/home-manager/_private/state/ports.nix @@ -1,64 +1,59 @@ { lib, ... }: -let - supportedProtocols = [ "tcp" "udp" ]; -in -{ - options.state = - let - portRangeType = { - options = { - from = lib.mkOption { - type = lib.types.port; - description = '' - The start of the range of TCP/UDP ports to be taken over. - ''; - }; +let supportedProtocols = [ "tcp" "udp" ]; +in { + options.state = let + portRangeType = { + options = { + from = lib.mkOption { + type = lib.types.port; + description = '' + The start of the range of TCP/UDP ports to be taken over. + ''; + }; - to = lib.mkOption { - type = lib.types.port; - description = '' - The end of the range of TCP/UDP ports to be taken over. - ''; - }; + to = lib.mkOption { + type = lib.types.port; + description = '' + The end of the range of TCP/UDP ports to be taken over. + ''; }; }; - - portValueModule = { lib, ... }: { - options = { - protocols = lib.mkOption { - type = with lib.types; listOf (enum supportedProtocols); - description = '' - Indicates the type of protocol of the service. - ''; - default = [ "tcp" "udp" ]; - example = [ "tcp" ]; - }; - - value = lib.mkOption { - type = with lib.types; either port (submodule portRangeType); - description = '' - The port number itself. - ''; - }; - }; - }; - - portsSubmodule = { lib, ... }: { - options = { - ports = lib.mkOption { - type = with lib.types; attrsOf (submodule portValueModule); - default = { }; - example = lib.literalExpression '' - { - gonic.value = 4629; - mopidy.value = 6034; - } - ''; - }; - }; - }; - in lib.mkOption { - type = lib.types.submodule portsSubmodule; }; + + portValueModule = { lib, ... }: { + options = { + protocols = lib.mkOption { + type = with lib.types; listOf (enum supportedProtocols); + description = '' + Indicates the type of protocol of the service. + ''; + default = [ "tcp" "udp" ]; + example = [ "tcp" ]; + }; + + value = lib.mkOption { + type = with lib.types; either port (submodule portRangeType); + description = '' + The port number itself. + ''; + }; + }; + }; + + portsSubmodule = { lib, ... }: { + options = { + ports = lib.mkOption { + type = with lib.types; attrsOf (submodule portValueModule); + default = { }; + example = lib.literalExpression '' + { + gonic.value = 4629; + mopidy.value = 6034; + } + ''; + }; + }; + }; + in lib.mkOption { type = lib.types.submodule portsSubmodule; }; } diff --git a/modules/home-manager/_private/suites/desktop.nix b/modules/home-manager/_private/suites/desktop.nix index c8ff39da..03a957e6 100644 --- a/modules/home-manager/_private/suites/desktop.nix +++ b/modules/home-manager/_private/suites/desktop.nix @@ -1,10 +1,8 @@ # Enables all of my usual setup for desktop-oriented stuff. { config, lib, pkgs, ... }@attrs: -let - cfg = config.suites.desktop; -in -{ +let cfg = config.suites.desktop; +in { options.suites.desktop = { enable = lib.mkEnableOption "installations of desktop apps"; graphics.enable = @@ -29,45 +27,41 @@ in config = lib.mkIf cfg.enable (lib.mkMerge [ (lib.mkIf cfg.graphics.enable { - home.packages = with pkgs; [ - aseprite # Pixel art wannabe tool. - emulsion-palette # Manage your color palettes. - eyedropper # Gotta keep your monitor moist. - inkscape-with-extensions # Illustration wannabe tool. - gimp-with-plugins # Photo editing wannabe tool. - krita # Digital art wannabe tool. - pureref # Pure references. + home.packages = with pkgs; + [ + aseprite # Pixel art wannabe tool. + emulsion-palette # Manage your color palettes. + eyedropper # Gotta keep your monitor moist. + inkscape-with-extensions # Illustration wannabe tool. + gimp-with-plugins # Photo editing wannabe tool. + krita # Digital art wannabe tool. + pureref # Pure references. - ffmpeg-full # Ah yes, everyman's multimedia swiss army knife. - imagemagick # Ah yes, everyman's image manipulation tool. - gmic # Don't let the gimmicks fool you, it's a magical image framework. - ] - ++ ( - let - hasBlenderNixOSModule = attrs.nixosConfig.programs.blender.enable or false; - in - lib.optional (!hasBlenderNixOSModule) pkgs.blender - ); + ffmpeg-full # Ah yes, everyman's multimedia swiss army knife. + imagemagick # Ah yes, everyman's image manipulation tool. + gmic # Don't let the gimmicks fool you, it's a magical image framework. + ] ++ (let + hasBlenderNixOSModule = + attrs.nixosConfig.programs.blender.enable or false; + in lib.optional (!hasBlenderNixOSModule) pkgs.blender); }) (lib.mkIf cfg.audio.enable { - home.packages = with pkgs; [ - audacity # EGADS!!! - musescore # You won't find muses to score, only music: a common misconception. - zrythm # The freer FL Studio (if you're sailing by the high seven seas). - supercollider-with-plugins # Not to be confused with the other Super Collider. - sonic-pi # The only pie you'll get from this is worms which I heard is addicting. - ffmpeg-full # Ah yes, everyman's multimedia swiss army knife. - ] - ++ ( - let - hasDesktopSuiteEnabled = attrs.nixosConfig.suites.desktop.enable or false; - in - lib.optionals hasDesktopSuiteEnabled (with pkgs; [ + home.packages = with pkgs; + [ + audacity # EGADS!!! + musescore # You won't find muses to score, only music: a common misconception. + zrythm # The freer FL Studio (if you're sailing by the high seven seas). + supercollider-with-plugins # Not to be confused with the other Super Collider. + sonic-pi # The only pie you'll get from this is worms which I heard is addicting. + ffmpeg-full # Ah yes, everyman's multimedia swiss army knife. + ] ++ (let + hasDesktopSuiteEnabled = + attrs.nixosConfig.suites.desktop.enable or false; + in lib.optionals hasDesktopSuiteEnabled (with pkgs; [ yabridge # Building bridges to Windows and Linux audio tools. yabridgectl # The bridge controller. - ]) - ); + ])); }) (lib.mkIf cfg.audio.pipewire.enable { @@ -75,11 +69,10 @@ in services.easyeffects.enable = true; services.fluidsynth = { enable = true; - soundService = - let - hasNixOSPipewirePulseEnabled = attrs.nixosConfig.services.pipewire.enable or false; - in - lib.mkIf hasNixOSPipewirePulseEnabled "pipewire-pulse"; + soundService = let + hasNixOSPipewirePulseEnabled = + attrs.nixosConfig.services.pipewire.enable or false; + in lib.mkIf hasNixOSPipewirePulseEnabled "pipewire-pulse"; }; home.packages = with pkgs; [ @@ -116,14 +109,10 @@ in enable = true; config = { ytdl-format = "(webm,mkv,mp4)[height<=?1280]"; - ytdl-raw-options-append = - let - options = { - yes-playlist = ""; - }; - options' = lib.mapAttrsToList (n: v: "${n}=${v}") options; - in - lib.concatStringsSep "," options'; + ytdl-raw-options-append = let + options = { yes-playlist = ""; }; + options' = lib.mapAttrsToList (n: v: "${n}=${v}") options; + in lib.concatStringsSep "," options'; ordered-chapters = true; ab-loop-count = "inf"; chapter-seek-threshold = 15.0; @@ -156,7 +145,8 @@ in profile-desc = "CJK prioritization"; vlang = "zho,zh,kor,ko,jpn,ja,eng,en"; alang = vlang; - slang = with lib; concatStringsSep "," (reverseList (splitString "," vlang)); + slang = with lib; + concatStringsSep "," (reverseList (splitString "," vlang)); }; "extension.gif" = { @@ -189,10 +179,8 @@ in ]; xdg.mimeApps.defaultApplications = { - "application/pdf" = [ - "sioyek.desktop" - "com.github.johnfactotum.Foliate.desktop" - ]; + "application/pdf" = + [ "sioyek.desktop" "com.github.johnfactotum.Foliate.desktop" ]; }; # Some PDF viewer with a penchant for research. diff --git a/modules/home-manager/_private/suites/dev.nix b/modules/home-manager/_private/suites/dev.nix index d529d903..d70783a8 100644 --- a/modules/home-manager/_private/suites/dev.nix +++ b/modules/home-manager/_private/suites/dev.nix @@ -5,25 +5,23 @@ let cfg = config.suites.dev; in { options.suites.dev = { - enable = - lib.mkEnableOption "basic set of programs for development setup"; - shell.enable = - lib.mkEnableOption "enhanced shell configuration"; + enable = lib.mkEnableOption "basic set of programs for development setup"; + shell.enable = lib.mkEnableOption "enhanced shell configuration"; extras.enable = lib.mkEnableOption "additional tools for development stuff"; shaders.enable = lib.mkEnableOption "tools for developing shaders"; - servers.enable = lib.mkEnableOption "toolkit for managing servers from your home"; - funsies.enable = lib.mkEnableOption "installation of command-line applications for funsies"; - coreutils-replacement.enable = lib.mkEnableOption "replacement of coreutils with sane default options"; + servers.enable = + lib.mkEnableOption "toolkit for managing servers from your home"; + funsies.enable = lib.mkEnableOption + "installation of command-line applications for funsies"; + coreutils-replacement.enable = + lib.mkEnableOption "replacement of coreutils with sane default options"; }; config = lib.mkIf cfg.enable (lib.mkMerge [ ({ # Contains a dev-adjacent list of directory names to be ignored usually # used in walking through directories. - state.paths.ignoreDirectories = [ - ".git" - ".direnv" - ]; + state.paths.ignoreDirectories = [ ".git" ".direnv" ]; home.packages = with pkgs; [ cookiecutter # Cookiecutter templates for your mama (which is you). @@ -93,26 +91,21 @@ in { # Echolocation. Since you're using a home-manager configuration, you're # most likely using Nix anyways. - programs.nix-index.enable = !attrs.nixosConfig.programs.nix-index.enable or false; + programs.nix-index.enable = + !attrs.nixosConfig.programs.nix-index.enable or false; }) # Level up your terminal-dwelling skills with these. (lib.mkIf cfg.shell.enable { # A fuzzy finder that enables fuzzy finding not furry finding, a common misconception. - programs.fzf = - let - fd = lib.getExe' pkgs.fd "fd"; - in - { - enable = true; - changeDirWidgetCommand = "${fd} --type directory --unrestricted"; - defaultCommand = "${fd} --type file --hidden"; - defaultOptions = let - skipDirectories' = lib.concatStringsSep "," config.state.paths.ignoreDirectories; - in [ - "--walker-skip=${skipDirectories'}" - ]; - }; + programs.fzf = { + enable = true; + changeDirWidgetCommand = "${fd} --type directory --unrestricted"; + defaultOptions = let + skipDirectories' = + lib.concatStringsSep "," config.state.paths.ignoreDirectories; + in [ "--walker-skip=${skipDirectories'}" ]; + }; # Supercharging your shell history. Just don't forget to flush them out # before doing questionable things. @@ -153,9 +146,10 @@ in { # Modern problems require modern tools. (lib.mkIf cfg.coreutils-replacement.enable { - home.packages = with pkgs; [ - fd # Welp, a reliable find. - ]; + home.packages = with pkgs; + [ + fd # Welp, a reliable find. + ]; # dog > sky dog > cat. programs.bat = { @@ -171,7 +165,8 @@ in { programs.eza = { enable = true; extraOptions = let - ignoreDirectories = lib.concatStringsSep "|" config.state.paths.ignoreDirectories; + ignoreDirectories = + lib.concatStringsSep "|" config.state.paths.ignoreDirectories; in [ "--group-directories-first" "--header" @@ -183,10 +178,7 @@ in { # RIP indeed to grep. programs.ripgrep = { enable = true; - arguments = [ - "--max-columns-preview" - "--colors=line:style:bold" - ]; + arguments = [ "--max-columns-preview" "--colors=line:style:bold" ]; }; }) diff --git a/modules/home-manager/_private/suites/editors.nix b/modules/home-manager/_private/suites/editors.nix index caa154bc..2cd7904a 100644 --- a/modules/home-manager/_private/suites/editors.nix +++ b/modules/home-manager/_private/suites/editors.nix @@ -22,9 +22,7 @@ in { withRuby = true; withNodeJs = true; - plugins = with pkgs.vimPlugins; [ - parinfer-rust - ]; + plugins = with pkgs.vimPlugins; [ parinfer-rust ]; }; xdg.mimeApps.defaultApplications = { diff --git a/modules/home-manager/files/mutable-files.nix b/modules/home-manager/files/mutable-files.nix index 02296330..28b6ec03 100644 --- a/modules/home-manager/files/mutable-files.nix +++ b/modules/home-manager/files/mutable-files.nix @@ -3,9 +3,8 @@ let cfg = config.home.mutableFile; - runtimeInputs = lib.makeBinPath (with pkgs; [ - coreutils archiver curl git gopass - ]); + runtimeInputs = + lib.makeBinPath (with pkgs; [ coreutils archiver curl git gopass ]); # An attribute set to be used to get the fetching script. fetchScript = _: value: @@ -13,28 +12,27 @@ let url = lib.escapeShellArg value.url; path = lib.escapeShellArg value.path; extraArgs = lib.escapeShellArgs value.extraArgs; - in - { + in { git = '' [ -d ${path} ] || git clone ${extraArgs} ${url} ${path} ''; fetch = '' [ -e ${path} ] || curl ${extraArgs} ${url} --output ${path}" ''; - archive = - let - extractScript = - if (value.extractPath == null) then - ''arc unarchive "/tmp/$filename" ${path}'' - else - ''arc extract "/tmp/$filename" ${lib.escapeShellArg value.extractPath} ${path}''; - in - '' - [ -e ${path} ] || { - filename=$(curl ${extraArgs} --output-dir /tmp --silent --show-error --write-out '%{filename_effective}' --remote-name --remote-header-name --location ${url}) - ${extractScript} - } - ''; + archive = let + extractScript = if (value.extractPath == null) then + ''arc unarchive "/tmp/$filename" ${path}'' + else + '' + arc extract "/tmp/$filename" ${ + lib.escapeShellArg value.extractPath + } ${path}''; + in '' + [ -e ${path} ] || { + filename=$(curl ${extraArgs} --output-dir /tmp --silent --show-error --write-out '%{filename_effective}' --remote-name --remote-header-name --location ${url}) + ${extractScript} + } + ''; gopass = '' [ -e ${path} ] || gopass clone ${extraArgs} ${url} --path ${path} ${extraArgs} ''; @@ -52,90 +50,91 @@ let # home-manager where it is expected to be limited to its associated home # directory. But that's for the user to know how their user interact with the # rest of the system. - fileType = baseDir: { name, config, options, ... }: { - options = { - url = lib.mkOption { - type = lib.types.str; - description = '' - The URL of the file to be fetched. - ''; - example = "https://github.com/foo-dogsquared/dotfiles.git"; - }; + fileType = baseDir: + { name, config, options, ... }: { + options = { + url = lib.mkOption { + type = lib.types.str; + description = '' + The URL of the file to be fetched. + ''; + example = "https://github.com/foo-dogsquared/dotfiles.git"; + }; - path = lib.mkOption { - type = lib.types.str; - description = '' - The path of the mutable file. By default, it will be relative to the - home directory. - ''; - example = lib.literalExpression "\${config.xdg.userDirs.documents}/top-secret"; - default = name; - apply = p: - if lib.hasPrefix "/" p then p else "${baseDir}/${p}"; - }; + path = lib.mkOption { + type = lib.types.str; + description = '' + The path of the mutable file. By default, it will be relative to the + home directory. + ''; + example = lib.literalExpression + "\${config.xdg.userDirs.documents}/top-secret"; + default = name; + apply = p: if lib.hasPrefix "/" p then p else "${baseDir}/${p}"; + }; - extractPath = lib.mkOption { - type = with lib.types; nullOr str; - description = '' - The path within the archive to be extracted. This is only used if the - type is `archive`. If the value is `null` then it will extract the - whole archive into the directory. - ''; - default = null; - example = "path/inside/of/the/archive"; - }; + extractPath = lib.mkOption { + type = with lib.types; nullOr str; + description = '' + The path within the archive to be extracted. This is only used if the + type is `archive`. If the value is `null` then it will extract the + whole archive into the directory. + ''; + default = null; + example = "path/inside/of/the/archive"; + }; - type = lib.mkOption { - type = lib.types.enum [ "git" "fetch" "archive" "gopass" "custom" ]; - description = '' - Type that configures the behavior for fetching the URL. + type = lib.mkOption { + type = lib.types.enum [ "git" "fetch" "archive" "gopass" "custom" ]; + description = '' + Type that configures the behavior for fetching the URL. - This accept only certain keywords. + This accept only certain keywords. - - For `fetch`, the file will be fetched with {command}`curl`. - - For `git`, it will be fetched with {command}`git clone`. - - For `archive`, the file will be fetched with {command}`curl` and - extracted before putting the file. - - For `gopass`, the file will be cloned with {command}`gopass`. - - For `custom`, the file will be passed with a user-given command. - The `extraArgs` option is now assumed to be a list of a command and - its arguments. To make executing commands possible with custom - scripts, the URL and the path is stored in shell variables `$url` and - `$path` respectively. + - For `fetch`, the file will be fetched with {command}`curl`. + - For `git`, it will be fetched with {command}`git clone`. + - For `archive`, the file will be fetched with {command}`curl` and + extracted before putting the file. + - For `gopass`, the file will be cloned with {command}`gopass`. + - For `custom`, the file will be passed with a user-given command. + The `extraArgs` option is now assumed to be a list of a command and + its arguments. To make executing commands possible with custom + scripts, the URL and the path is stored in shell variables `$url` and + `$path` respectively. - The default type is `fetch`. - ''; - default = "fetch"; - example = "git"; - }; + The default type is `fetch`. + ''; + default = "fetch"; + example = "git"; + }; - extraArgs = lib.mkOption { - type = with lib.types; listOf str; - description = '' - A list of extra arguments to be included with the fetch command. Take - note of the commands used for each type as documented from - {option}`config.home.mutableFile..type`. - ''; - default = [ ]; - example = [ "--depth" "1" ]; - }; + extraArgs = lib.mkOption { + type = with lib.types; listOf str; + description = '' + A list of extra arguments to be included with the fetch command. Take + note of the commands used for each type as documented from + {option}`config.home.mutableFile..type`. + ''; + default = [ ]; + example = [ "--depth" "1" ]; + }; - postScript = lib.mkOption { - type = lib.types.lines; - description = '' - A shell script fragment to be executed after the download. - ''; - default = ""; - example = lib.literalExpression '' - ''${config.xdg.configHome}/emacs/bin/doom install --no-config --no-fonts --install --force - ''; + postScript = lib.mkOption { + type = lib.types.lines; + description = '' + A shell script fragment to be executed after the download. + ''; + default = ""; + example = lib.literalExpression '' + ''${config.xdg.configHome}/emacs/bin/doom install --no-config --no-fonts --install --force + ''; + }; }; }; - }; -in -{ +in { options.home.mutableFile = lib.mkOption { - type = with lib.types; attrsOf (submodule (fileType config.home.homeDirectory)); + type = with lib.types; + attrsOf (submodule (fileType config.home.homeDirectory)); description = '' An attribute set of mutable files and directories to be declaratively put into the home directory. Take note this is not exactly pure (or @@ -173,43 +172,37 @@ in Type = "oneshot"; RemainAfterExit = true; - ExecStart = - let - mutableFilesCmds = lib.mapAttrsToList - (path: value: let - url = lib.escapeShellArg value.url; - path = lib.escapeShellArg value.path; - in - '' - ( - URL=${url} - FILEPATH=${path} - DIRNAME=$(dirname ${path}) - mkdir -p "$DIRNAME" - ${(fetchScript path value).${value.type}} - ) - '') - cfg; + ExecStart = let + mutableFilesCmds = lib.mapAttrsToList (path: value: + let + url = lib.escapeShellArg value.url; + path = lib.escapeShellArg value.path; + in '' + ( + URL=${url} + FILEPATH=${path} + DIRNAME=$(dirname ${path}) + mkdir -p "$DIRNAME" + ${(fetchScript path value).${value.type}} + ) + '') cfg; - shellScript = pkgs.writeShellScriptBin "fetch-mutable-files" '' + shellScript = pkgs.writeShellScriptBin "fetch-mutable-files" '' + export PATH=${runtimeInputs}''${PATH:-:$PATH} + ${lib.concatStringsSep "\n" mutableFilesCmds} + ''; + in lib.getExe shellScript; + + ExecStartPost = let + mutableFilesCmds = + lib.mapAttrsToList (path: value: value.postScript) cfg; + + shellScript = + pkgs.writeShellScriptBin "fetch-mutable-files-post-script" '' export PATH=${runtimeInputs}''${PATH:-:$PATH} ${lib.concatStringsSep "\n" mutableFilesCmds} ''; - in - lib.getExe shellScript; - - ExecStartPost = - let - mutableFilesCmds = lib.mapAttrsToList - (path: value: value.postScript) - cfg; - - shellScript = pkgs.writeShellScriptBin "fetch-mutable-files-post-script" '' - export PATH=${runtimeInputs}''${PATH:-:$PATH} - ${lib.concatStringsSep "\n" mutableFilesCmds} - ''; - in - lib.getExe shellScript; + in lib.getExe shellScript; }; Install.WantedBy = [ "default.target" ]; diff --git a/modules/home-manager/profiles/nix-conf.nix b/modules/home-manager/profiles/nix-conf.nix index 15c6cd60..fa41a439 100644 --- a/modules/home-manager/profiles/nix-conf.nix +++ b/modules/home-manager/profiles/nix-conf.nix @@ -20,9 +20,9 @@ # # Since we're using flakes to make this possible, we need it. Plus, the # UX of Nix CLI is becoming closer to Guix's which is a nice bonus. - experimental-features = - [ "nix-command" "flakes" ] - ++ lib.optionals (lib.versionOlder config.nix.package.version "2.22.0") [ "repl-flake" ]; + experimental-features = [ "nix-command" "flakes" ] + ++ lib.optionals (lib.versionOlder config.nix.package.version "2.22.0") + [ "repl-flake" ]; auto-optimise-store = lib.mkDefault true; # We don't want to download every time we invoke Nix, seriously. Thanks. diff --git a/modules/home-manager/programs/borgmatic.nix b/modules/home-manager/programs/borgmatic.nix index 8ebd5acc..99dd615a 100644 --- a/modules/home-manager/programs/borgmatic.nix +++ b/modules/home-manager/programs/borgmatic.nix @@ -46,7 +46,8 @@ let }; validateConfig = - lib.mkEnableOption "validation step for the resulting configuration" // { + lib.mkEnableOption "validation step for the resulting configuration" + // { default = true; }; }; @@ -55,26 +56,25 @@ let mkBorgmaticConfig = n: v: lib.nameValuePair "borgmatic.d/${n}.yaml" { source = let - settingsFile = settingsFormat.generate "borgmatic-config-${n}" v.settings; + settingsFile = + settingsFormat.generate "borgmatic-config-${n}" v.settings; borgmaticValidateCmd = if lib.versionOlder cfg.package.version "1.7.15" then "borgmatic config validate --config ${settingsFile}" else "validate-borgmatic-config --config ${settingsFile}"; - in - if v.validateConfig then - pkgs.runCommand "generate-borgmatic-config-with-validation" { - buildInputs = [ cfg.package ]; - preferLocalBuild = true; - } '' - ${borgmaticValidateCmd} && install ${settingsFile} $out - '' - else - settingsFile; + in if v.validateConfig then + pkgs.runCommand "generate-borgmatic-config-with-validation" { + buildInputs = [ cfg.package ]; + preferLocalBuild = true; + } '' + ${borgmaticValidateCmd} && install ${settingsFile} $out + '' + else + settingsFile; }; - in -{ +in { disabledModules = [ "programs/borgmatic.nix" ]; options.programs.borgmatic = { enable = lib.mkEnableOption "configuring Borg backups with Borgmatic"; diff --git a/modules/home-manager/programs/nushell.nix b/modules/home-manager/programs/nushell.nix index 886d41cf..b775e8e0 100644 --- a/modules/home-manager/programs/nushell.nix +++ b/modules/home-manager/programs/nushell.nix @@ -2,14 +2,17 @@ # variables since the one from home-manager is only in POSIX sh script. { config, lib, pkgs, ... }: -let - cfg = config.programs.nushell; -in -{ +let cfg = config.programs.nushell; +in { config.programs.nushell.extraEnv = let - exportSessionVariables = lib.mapAttrs (n: v: - "$env.${n} = ${v}") config.home.sessionVariables; - in lib.mkBefore '' - ${exportSessionVariables} - ''; + exportToNuEnv = vars: + lib.concatStringsSep "\n" + (lib.mapAttrsToList (n: v: ''$env.${n} = "${v}"'') vars); + in lib.mkBefore ('' + ${exportToNuEnv config.home.sessionVariables} + '' + lib.optionalString (config.home.sessionPath != [ ]) '' + $env.PATH = $env.PATH | split row ':' | prepend [ + ${lib.concatStringsSep " " config.home.sessionPath} + ] + ''); } diff --git a/modules/home-manager/programs/pipewire.nix b/modules/home-manager/programs/pipewire.nix index df669072..62f0a825 100644 --- a/modules/home-manager/programs/pipewire.nix +++ b/modules/home-manager/programs/pipewire.nix @@ -6,10 +6,10 @@ let generatePipewireConfig = name: settings: lib.nameValuePair "pipewire/pipewire.conf.d/${name}.conf" { - source = settingsFormat.generate "hm-pipewire-override-settings-${name}" settings; + source = settingsFormat.generate "hm-pipewire-override-settings-${name}" + settings; }; -in -{ +in { options.programs.pipewire = { enable = lib.mkEnableOption "Pipewire configuration"; settings = lib.mkOption { @@ -38,11 +38,9 @@ in }; config = lib.mkIf cfg.enable { - xdg.configFile = - lib.optionalAttrs (cfg.settings != { }) - { - "pipewire/pipewire.conf".source = settingsFormat.generate "hm-pipewire-settings" cfg.settings; - } - // lib.mapAttrs' generatePipewireConfig cfg.overrides; + xdg.configFile = lib.optionalAttrs (cfg.settings != { }) { + "pipewire/pipewire.conf".source = + settingsFormat.generate "hm-pipewire-settings" cfg.settings; + } // lib.mapAttrs' generatePipewireConfig cfg.overrides; }; } diff --git a/modules/home-manager/programs/pop-launcher.nix b/modules/home-manager/programs/pop-launcher.nix index 678422dc..4a53c14f 100644 --- a/modules/home-manager/programs/pop-launcher.nix +++ b/modules/home-manager/programs/pop-launcher.nix @@ -9,8 +9,7 @@ let name = "pop-launcher-plugins-system"; paths = builtins.map (p: "${p}/share/pop-launcher") cfg.plugins; }; -in -{ +in { options.programs.pop-launcher = { enable = lib.mkOption { description = '' diff --git a/modules/home-manager/programs/python.nix b/modules/home-manager/programs/python.nix index 80e7c2e9..86ad2bb9 100644 --- a/modules/home-manager/programs/python.nix +++ b/modules/home-manager/programs/python.nix @@ -1,9 +1,7 @@ { config, lib, pkgs, ... }: -let - cfg = config.programs.python; -in -{ +let cfg = config.programs.python; +in { options.programs.python = { enable = lib.mkEnableOption "user-wide Python installation"; package = lib.mkPackageOption pkgs "python3" { }; @@ -23,8 +21,6 @@ in }; config = lib.mkIf cfg.enable { - home.packages = [ - (cfg.package.withPackages cfg.modules) - ]; + home.packages = [ (cfg.package.withPackages cfg.modules) ]; }; } diff --git a/modules/home-manager/services/archivebox.nix b/modules/home-manager/services/archivebox.nix index d4c3de62..a30c487a 100644 --- a/modules/home-manager/services/archivebox.nix +++ b/modules/home-manager/services/archivebox.nix @@ -40,8 +40,7 @@ let }; }; }; -in -{ +in { options.services.archivebox = { enable = lib.mkEnableOption "Archivebox service"; @@ -93,91 +92,83 @@ in }; }; - config = - let - pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies - (with pkgs; [ chromium nodejs_latest wget curl youtube-dl ])); - in - lib.mkIf cfg.enable { - assertions = [ - (lib.hm.assertions.assertPlatform "services.archivebox" pkgs - lib.platforms.linux) - ]; + config = let + pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies + (with pkgs; [ chromium nodejs_latest wget curl youtube-dl ])); + in lib.mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.archivebox" pkgs + lib.platforms.linux) + ]; - home.packages = pkgSet; + home.packages = pkgSet; - systemd.user.services = lib.mkMerge [ - (lib.mapAttrs' - (name: value: - lib.nameValuePair (jobUnitName name) { - Unit = { - Description = - "Archivebox archive group '${name}' for ${cfg.archivePath}"; - After = [ "network-online.target" ]; - Documentation = [ "https://docs.archivebox.io/" ]; - }; + systemd.user.services = lib.mkMerge [ + (lib.mapAttrs' (name: value: + lib.nameValuePair (jobUnitName name) { + Unit = { + Description = + "Archivebox archive group '${name}' for ${cfg.archivePath}"; + After = [ "network-online.target" ]; + Documentation = [ "https://docs.archivebox.io/" ]; + }; - Service = - let - scriptName = "archivebox-job-${config.home.username}-${name}"; - script = pkgs.writeShellApplication { - name = scriptName; - runtimeInputs = with pkgs; - [ ripgrep coreutils ] ++ pkgSet - ++ [ config.programs.git.package ]; - text = '' - echo "${lib.concatStringsSep "\n" value.links}" \ - | archivebox add ${lib.concatStringsSep " " value.extraArgs} - ''; - }; - in - { - ExecStart = "${script}/bin/${scriptName}"; - WorkingDirectory = cfg.archivePath; - }; - }) - cfg.jobs) - - (lib.mkIf cfg.webserver.enable { - archivebox-server = { - Unit = { - Description = "Archivebox server for ${cfg.archivePath}"; - After = [ "network-online.target" ]; - Wants = [ "network-online.target" ]; - Documentation = [ "https://docs.archivebox.io/" ]; + Service = let + scriptName = "archivebox-job-${config.home.username}-${name}"; + script = pkgs.writeShellApplication { + name = scriptName; + runtimeInputs = with pkgs; + [ ripgrep coreutils ] ++ pkgSet + ++ [ config.programs.git.package ]; + text = '' + echo "${lib.concatStringsSep "\n" value.links}" \ + | archivebox add ${lib.concatStringsSep " " value.extraArgs} + ''; }; + in { + ExecStart = "${script}/bin/${scriptName}"; + WorkingDirectory = cfg.archivePath; + }; + }) cfg.jobs) - Install.WantedBy = [ "graphical-session.target" ]; + (lib.mkIf cfg.webserver.enable { + archivebox-server = { + Unit = { + Description = "Archivebox server for ${cfg.archivePath}"; + After = [ "network-online.target" ]; + Wants = [ "network-online.target" ]; + Documentation = [ "https://docs.archivebox.io/" ]; + }; - Service = { - ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${ + Install.WantedBy = [ "graphical-session.target" ]; + + Service = { + ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${ toString cfg.webserver.port }"; - WorkingDirectory = cfg.archivePath; - Restart = "on-failure"; - }; + WorkingDirectory = cfg.archivePath; + Restart = "on-failure"; }; - }) - ]; + }; + }) + ]; - systemd.user.timers = lib.mapAttrs' - (name: value: - lib.nameValuePair (jobUnitName name) { - Unit = { - Description = "Archivebox additions for ${cfg.archivePath}"; - After = [ "network-online.target" ]; - Wants = [ "network-online.target" ]; - Documentation = [ "https://docs.archivebox.io/" ]; - }; + systemd.user.timers = lib.mapAttrs' (name: value: + lib.nameValuePair (jobUnitName name) { + Unit = { + Description = "Archivebox additions for ${cfg.archivePath}"; + After = [ "network-online.target" ]; + Wants = [ "network-online.target" ]; + Documentation = [ "https://docs.archivebox.io/" ]; + }; - Timer = { - Persistent = true; - OnCalendar = value.startAt; - RandomizedDelaySec = 120; - }; + Timer = { + Persistent = true; + OnCalendar = value.startAt; + RandomizedDelaySec = 120; + }; - Install.WantedBy = [ "timers.target" ]; - }) - cfg.jobs; - }; + Install.WantedBy = [ "timers.target" ]; + }) cfg.jobs; + }; } diff --git a/modules/home-manager/services/bleachbit.nix b/modules/home-manager/services/bleachbit.nix index 9797e374..0b027ddf 100644 --- a/modules/home-manager/services/bleachbit.nix +++ b/modules/home-manager/services/bleachbit.nix @@ -3,52 +3,52 @@ let cfg = config.services.bleachbit; - cleaners = lib.lists.unique (cfg.cleaners ++ lib.optionals cfg.withBrowserCleanup [ - "brave.cache" - "brave.form_history" - "brave.history" - "brave.passwords" - "chromium.cache" - "chromium.form_history" - "chromium.history" - "chromium.passwords" - "epiphany.cache" - "epiphany.passwords" - "firefox.cache" - "firefox.forms" - "firefox.passwords" - "firefox.url_history" - "google_chrome.cache" - "google_chrome.form_history" - "google_chrome.history" - "opera.cache" - "opera.form_history" - "opera.history" - "palemoon.cache" - "palemoon.forms" - "palemoon.passwords" - "palemoon.url_history" - "waterfox.cache" - "waterfox.forms" - "waterfox.passwords" - "waterfox.url_history" - ] ++ lib.optionals cfg.withChatCleanup [ - "discord.cache" - "discord.history" - "skype.chat_logs" - "skype.installers" - "slack.cache" - "slack.cookies" - "slack.history" - "slack.vacuum" - "thunderbird.cache" - "thunderbird.cookies" - "thunderbird.index" - "thunderbird.passwords" - "thunderbird.sessionjson" - ]); -in -{ + cleaners = lib.lists.unique (cfg.cleaners + ++ lib.optionals cfg.withBrowserCleanup [ + "brave.cache" + "brave.form_history" + "brave.history" + "brave.passwords" + "chromium.cache" + "chromium.form_history" + "chromium.history" + "chromium.passwords" + "epiphany.cache" + "epiphany.passwords" + "firefox.cache" + "firefox.forms" + "firefox.passwords" + "firefox.url_history" + "google_chrome.cache" + "google_chrome.form_history" + "google_chrome.history" + "opera.cache" + "opera.form_history" + "opera.history" + "palemoon.cache" + "palemoon.forms" + "palemoon.passwords" + "palemoon.url_history" + "waterfox.cache" + "waterfox.forms" + "waterfox.passwords" + "waterfox.url_history" + ] ++ lib.optionals cfg.withChatCleanup [ + "discord.cache" + "discord.history" + "skype.chat_logs" + "skype.installers" + "slack.cache" + "slack.cookies" + "slack.history" + "slack.vacuum" + "thunderbird.cache" + "thunderbird.cookies" + "thunderbird.index" + "thunderbird.passwords" + "thunderbird.sessionjson" + ]); +in { options.services.bleachbit = { enable = lib.mkEnableOption "automated cleanup with Bleachbit"; startAt = lib.mkOption { diff --git a/modules/home-manager/services/borgbackup.nix b/modules/home-manager/services/borgbackup.nix index 21d98a6a..783e6616 100644 --- a/modules/home-manager/services/borgbackup.nix +++ b/modules/home-manager/services/borgbackup.nix @@ -8,9 +8,11 @@ let borgJobsModule = { name, lib, config, ... }: { options = { - exportWrapperScript = lib.mkEnableOption "export wrapper script as part of the environment" // { - default = true; - }; + exportWrapperScript = + lib.mkEnableOption "export wrapper script as part of the environment" + // { + default = true; + }; extraArgs = lib.mkOption { type = with lib.types; listOf str; @@ -25,9 +27,7 @@ let ::: ''; default = [ ]; - example = [ - "--remote-path=/path/to/borg/repo" - ]; + example = [ "--remote-path=/path/to/borg/repo" ]; }; extraCreateArgs = lib.mkOption { @@ -36,10 +36,7 @@ let Additional arguments for `borg create`. ''; default = [ ]; - example = [ - "--stats" - "--checkpoint-interval" "600" - ]; + example = [ "--stats" "--checkpoint-interval" "600" ]; }; extraInitArgs = lib.mkOption { @@ -48,10 +45,7 @@ let Extra arguments to be passed to `borg init`, when applicable. ''; default = [ ]; - example = [ - "--make-parent-dirs" - "--append-only" - ]; + example = [ "--make-parent-dirs" "--append-only" ]; }; patternFiles = lib.mkOption { @@ -129,60 +123,85 @@ let mkPassEnv = v: # Prefer the pass command option since it is the safer option. - if v.encryption.passCommand != null - then { BORG_PASSCOMMAND = v.encryption.passCommand; } - else if v.encryption.passphrase != null - then { BORG_PASSPHRASE = v.encryption.passphrase; } - else { }; + if v.encryption.passCommand != null then { + BORG_PASSCOMMAND = v.encryption.passCommand; + } else if v.encryption.passphrase != null then { + BORG_PASSPHRASE = v.encryption.passphrase; + } else + { }; makeJobName = name: "borg-job-${name}"; mkBorgWrapperScripts = n: v: let executableName = makeJobName n; setEnv = { BORG_REPO = v.repo; } // (mkPassEnv v) // v.environment; - mkWrapperFlag = n: v: - ''--set ${lib.escapeShellArg n} "${v}"''; - in - pkgs.runCommand "${n}-wrapper" { + mkWrapperFlag = n: v: ''--set ${lib.escapeShellArg n} "${v}"''; + in pkgs.runCommand "${n}-wrapper" { nativeBuildInputs = [ pkgs.makeWrapper ]; } '' - makeWrapper "${lib.getExe' cfg.package "borg"} "$out/bin/${executableName}" \ - ${lib.concatStringsSep " \\\n" (lib.mapAttrsToList mkWrapperFlag setEnv)} + makeWrapper "${ + lib.getExe' cfg.package "borg" + } "$out/bin/${executableName}" \ + ${ + lib.concatStringsSep " \\\n" (lib.mapAttrsToList mkWrapperFlag setEnv) + } ''; mkBorgServiceUnit = n: v: lib.nameValuePair (makeJobName n) { - Unit = { - Description = "Periodic BorgBackup job '${n}'"; - }; + Unit = { Description = "Periodic BorgBackup job '${n}'"; }; Service = { CPUSchedulingPolicy = "idle"; IOSchedulingClass = "idle"; - Environment = - lib.attrsToList (n: v: "${n}=${v}") ( - { - inherit (v) extraArgs extraInitArgs extraCreateArgs; - } - // v.environment // (mkPassEnv v) - ) - ++ [ - "BORG_REPO=${v.repo}" - ]; + Environment = lib.attrsToList (n: v: "${n}=${v}") ({ + inherit (v) extraArgs extraInitArgs extraCreateArgs; + } // v.environment // (mkPassEnv v)) ++ [ "BORG_REPO=${v.repo}" ]; - ExecStart = - let - borgScript = pkgs.writeShellApplication { - name = "borg-job-${n}-script"; - runtimeInputs = [ cfg.package ]; - text = '' - on_exit() { - } - trap on_exit EXIT - ''; - }; - in - lib.getExe borgScript; + ExecStart = let + borgScript = pkgs.writeShellApplication { + name = "borg-job-${n}-script"; + runtimeInputs = [ cfg.package ]; + text = '' + on_exit() { + exitStatus=$? + ${cfg.postHook} + exit $exitStatus + } + trap on_exit EXIT + + borgWrapper () { + local result + borg "$@" && result=$? || result=$? + if [[ -z "${ + toString cfg.failOnWarnings + }" ]] && [[ "$result" == 1 ]]; then + echo "ignoring warning return value 1" + return 0 + else + return "$result" + fi + } + + archiveName="${ + lib.optionalString (cfg.archiveBaseName != null) + (cfg.archiveBaseName + "-") + }$(date ${cfg.dateFormat})" + archiveSuffix="${ + lib.optionalString cfg.appendFailedSuffix ".failed" + }" + ${cfg.preHook} + '' + lib.optionalString cfg.doInit '' + # Run borg init if the repo doesn't exist yet + if ! borgWrapper list $extraArgs > /dev/null; then + borgWrapper init $extraArgs \ + --encryption ${cfg.encryption.mode} \ + $extraInitArgs + ${cfg.postInit} + fi + ''; + }; + in lib.getExe borgScript; }; }; @@ -198,8 +217,7 @@ let Install.WantedBy = [ "timers.target" ]; }; -in -{ +in { options.services.borgbackup = { enable = lib.mkEnableOption "periodic backups with BorgBackup"; @@ -235,15 +253,11 @@ in config = lib.mkIf cfg.enable { home.packages = - let - jobs' = lib.filterAttrs (n: v: v.exportWrapperScript) cfg.jobs; - in - lib.mapAttrsToList mkBorgWrapperScripts jobs'; + let jobs' = lib.filterAttrs (n: v: v.exportWrapperScript) cfg.jobs; + in lib.mapAttrsToList mkBorgWrapperScripts jobs'; - systemd.user.services = - lib.mapAttrs' mkBorgServiceUnit cfg.jobs; + systemd.user.services = lib.mapAttrs' mkBorgServiceUnit cfg.jobs; - systemd.user.timers = - lib.mapAttrs' mkBorgTimerUnit cfg.jobs; + systemd.user.timers = lib.mapAttrs' mkBorgTimerUnit cfg.jobs; }; } diff --git a/modules/home-manager/services/borgmatic.nix b/modules/home-manager/services/borgmatic.nix index 63d59cd6..197219db 100644 --- a/modules/home-manager/services/borgmatic.nix +++ b/modules/home-manager/services/borgmatic.nix @@ -19,7 +19,8 @@ let borgmaticProgramModule = { name, lib, ... }: { options = { initService = { - enable = lib.mkEnableOption "include this particular backup as part of Borgmatic jobset at {option}`services.borgmatic.jobs`"; + enable = lib.mkEnableOption + "include this particular backup as part of Borgmatic jobset at {option}`services.borgmatic.jobs`"; startAt = lib.mkOption { type = lib.types.nonEmptyStr; @@ -34,88 +35,86 @@ let }; }; - borgmaticJobModule = { config, lib, name, ... }: let - settingsFile = settingsFormat.generate "borgmatic-job-config-${name}" config.settings; - in { - options = { - settings = lib.mkOption { - type = settingsFormat.type; - description = '' - Configuration settings associated with the job. If this is set, the - generated output is added as an additional argument (i.e., `--config - SETTINGSFILE`) in the service script. - ''; - default = { }; - example = lib.literalExpression '' - { - source_directories = [ - config.xdg.userDirs.document - config.xdg.userDirs.download - config.xdg.userDirs.music - config.xdg.userDirs.video - ]; + borgmaticJobModule = { config, lib, name, ... }: + let + settingsFile = + settingsFormat.generate "borgmatic-job-config-${name}" config.settings; + in { + options = { + settings = lib.mkOption { + type = settingsFormat.type; + description = '' + Configuration settings associated with the job. If this is set, the + generated output is added as an additional argument (i.e., `--config + SETTINGSFILE`) in the service script. + ''; + default = { }; + example = lib.literalExpression '' + { + source_directories = [ + config.xdg.userDirs.document + config.xdg.userDirs.download + config.xdg.userDirs.music + config.xdg.userDirs.video + ]; - keep_daily = 5; - keep_weekly = 10; - keep_monthly = 20; + keep_daily = 5; + keep_weekly = 10; + keep_monthly = 20; - repositories = lib.singleton { - path = "ssh://asodajdoiasjdoij"; - label = "remote"; - }; - } - ''; + repositories = lib.singleton { + path = "ssh://asodajdoiasjdoij"; + label = "remote"; + }; + } + ''; + }; + + startAt = lib.mkOption { + type = lib.types.nonEmptyStr; + description = '' + Indicates how often backup will occur. This is to be used as value + for `Timer.OnCalendar=` in the systemd unit. See + {manpage}`systemd.time(7)` for more details. + ''; + default = "daily"; + example = "04:30"; + }; + + extraArgs = lib.mkOption { + type = with lib.types; listOf str; + description = '' + List of arguments to be passed to the Borgmatic backup service. + ''; + default = [ ]; + example = lib.literalExpression '' + [ + "--stats" + "--verbosity" "1" + "--syslog-verbosity" "1" + "--list" + ] + ''; + }; }; - startAt = lib.mkOption { - type = lib.types.nonEmptyStr; - description = '' - Indicates how often backup will occur. This is to be used as value - for `Timer.OnCalendar=` in the systemd unit. See - {manpage}`systemd.time(7)` for more details. - ''; - default = "daily"; - example = "04:30"; - }; + config = { + extraArgs = lib.mkMerge [ + cfg.extraArgs - extraArgs = lib.mkOption { - type = with lib.types; listOf str; - description = '' - List of arguments to be passed to the Borgmatic backup service. - ''; - default = [ ]; - example = lib.literalExpression '' - [ - "--stats" - "--verbosity" "1" - "--syslog-verbosity" "1" - "--list" - ] - ''; + (lib.optionals (config.settings != { }) + (lib.mkBefore [ "--config" settingsFile ])) + ]; }; }; - config = { - extraArgs = lib.mkMerge [ - cfg.extraArgs - - (lib.optionals (config.settings != {}) ( - lib.mkBefore [ - "--config" settingsFile - ] - )) - ]; - }; - }; - formatUnitName = name: "borgmatic-job-${name}"; mkBorgmaticServiceUnit = n: v: lib.nameValuePair (formatUnitName n) { Unit = { Description = "Borgmatic backup job '${n}'"; - Documentation = [ - "https://torsion.org/borgmatic/docs/reference/configuration" - ]; + Documentation = + [ "https://torsion.org/borgmatic/docs/reference/configuration" ]; ConditionACPower = true; StartLimitBurst = 5; }; @@ -132,7 +131,9 @@ let LogRateLimitIntervalSec = 0; ExecStart = '' - ${lib.getExe' cfg.package "borgmatic"} ${lib.concatStringsSep " " v.extraArgs} + ${lib.getExe' cfg.package "borgmatic"} ${ + lib.concatStringsSep " " v.extraArgs + } ''; PrivateTmp = true; @@ -155,12 +156,10 @@ let mkBorgmaticServiceFromConfig = n: v: lib.nameValuePair "borgmatic-config-${n}" { inherit (v.initService) startAt; - extraArgs = [ - "--config" "${config.xdg.configHome}/borgmatic.d/${n}.yaml" - ]; + extraArgs = + [ "--config" "${config.xdg.configHome}/borgmatic.d/${n}.yaml" ]; }; -in -{ +in { disabledModules = [ "services/borgmatic.nix" ]; options.programs.borgmatic.backups = lib.mkOption { type = with lib.types; attrsOf (submodule borgmaticProgramModule); @@ -175,60 +174,54 @@ in Global list of additional arguments for all of the jobs. ''; default = [ ]; - example = [ - "--stats" - "--verbosity" "1" - ]; + example = [ "--stats" "--verbosity" "1" ]; }; jobs = lib.mkOption { type = with lib.types; attrsOf (submodule borgmaticJobModule); default = { }; - example = lib.literalExpression '' - { - personal = { - startAt = "05:30"; - settings = { - source_directories = [ - "''${config.xdg.configHome}" - "''${config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR}" - "''${config.home.homeDirectory}/.thunderbird" - "''${config.home.homeDirectory}/Zotero" - ]; + example = lib.literalExpression '' + { + personal = { + startAt = "05:30"; + settings = { + source_directories = [ + "''${config.xdg.configHome}" + "''${config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR}" + "''${config.home.homeDirectory}/.thunderbird" + "''${config.home.homeDirectory}/Zotero" + ]; - repositories = [ - { - path = "ssh://k8pDxu32@k8pDxu32.repo.borgbase.com/./repo"; - label = "borgbase"; - } + repositories = [ + { + path = "ssh://k8pDxu32@k8pDxu32.repo.borgbase.com/./repo"; + label = "borgbase"; + } - { - path = "/var/lib/backups/local.borg"; - label = "local"; - } - ]; + { + path = "/var/lib/backups/local.borg"; + label = "local"; + } + ]; - keep_daily = 7; - keep_weekly = 4; - keep_monthly = 6; - }; + keep_daily = 7; + keep_weekly = 4; + keep_monthly = 6; }; - } - ''; - }; + }; + } + ''; }; + }; config = { - systemd.user.services = - lib.mapAttrs' mkBorgmaticServiceUnit cfg.jobs; + systemd.user.services = lib.mapAttrs' mkBorgmaticServiceUnit cfg.jobs; - systemd.user.timers = - lib.mapAttrs' mkBorgmaticTimerUnit cfg.jobs; + systemd.user.timers = lib.mapAttrs' mkBorgmaticTimerUnit cfg.jobs; - services.borgmatic.jobs = - let - validService = lib.filterAttrs (n: v: v.initService.enable) programCfg.backups; - in - lib.mapAttrs' mkBorgmaticServiceFromConfig validService; + services.borgmatic.jobs = let + validService = + lib.filterAttrs (n: v: v.initService.enable) programCfg.backups; + in lib.mapAttrs' mkBorgmaticServiceFromConfig validService; }; } diff --git a/modules/home-manager/services/distant.nix b/modules/home-manager/services/distant.nix index b437ad63..489fae83 100644 --- a/modules/home-manager/services/distant.nix +++ b/modules/home-manager/services/distant.nix @@ -4,12 +4,13 @@ let cfg = config.services.distant; settingsFormat = pkgs.formats.toml { }; - settingsFile = settingsFormat.generate "distant-settings-${config.home.username}" cfg.settings; + settingsFile = + settingsFormat.generate "distant-settings-${config.home.username}" + cfg.settings; hasCustomSocketPath = cfg.settings.manager.unix_socket != null; defaultSocketPath = "%t/distant/%u.distant.sock"; -in -{ +in { options.services.distant = { enable = lib.mkEnableOption "Distant-related services"; @@ -47,7 +48,12 @@ in Service = { ExecStart = '' - ${lib.getBin cfg.package}/bin/distant manager listen --config ${settingsFile} ${lib.optionalString (!hasCustomSocketPath) "--unix-socket ${defaultSocketPath}"} + ${ + lib.getBin cfg.package + }/bin/distant manager listen --config ${settingsFile} ${ + lib.optionalString (!hasCustomSocketPath) + "--unix-socket ${defaultSocketPath}" + } ''; Restart = "on-failure"; }; @@ -61,7 +67,10 @@ in Documentation = [ "https://distant.dev" ]; }; - Socket.ListenStream = if hasCustomSocketPath then cfg.settings.manager.unix_socket else defaultSocketPath; + Socket.ListenStream = if hasCustomSocketPath then + cfg.settings.manager.unix_socket + else + defaultSocketPath; }; systemd.user.services.distant-server = lib.mkIf cfg.server.enable { @@ -72,7 +81,9 @@ in Service = { ExecStart = '' - ${lib.getBin cfg.package}/bin/distant server listen --config ${settingsFile} + ${ + lib.getBin cfg.package + }/bin/distant server listen --config ${settingsFile} ''; Restart = "on-failure"; StandardInput = "socket"; diff --git a/modules/home-manager/services/gallery-dl.nix b/modules/home-manager/services/gallery-dl.nix index 7581923f..5d66b1a0 100644 --- a/modules/home-manager/services/gallery-dl.nix +++ b/modules/home-manager/services/gallery-dl.nix @@ -8,7 +8,7 @@ let settingsFormat = pkgs.formats.json { }; settingsFormatFile = settingsFormat.generate "gallery-dl-service-config-${config.home.username}" - cfg.settings; + cfg.settings; jobType = { name, config, options, ... }: { options = { @@ -78,15 +78,13 @@ let }; }; }; -in -{ +in { options.services.gallery-dl = { enable = lib.mkEnableOption "archiving services with gallery-dl"; package = lib.mkOption { type = lib.types.package; - description = - "Package containing the {command}`gallery-dl` binary."; + description = "Package containing the {command}`gallery-dl` binary."; default = pkgs.gallery-dl; defaultText = lib.literalExpression "pkgs.gallery-dl"; }; @@ -120,8 +118,7 @@ in extraArgs = lib.mkOption { type = with lib.types; listOf str; - description = - "List of arguments to be passed to {command}`gallery-dl`."; + description = "List of arguments to be passed to {command}`gallery-dl`."; default = [ ]; example = lib.literalExpression '' [ @@ -160,53 +157,47 @@ in config = lib.mkIf cfg.enable { home.packages = [ cfg.package ]; - systemd.user.services = lib.mapAttrs' - (name: value: - lib.nameValuePair (jobUnitName name) { - Unit = { - Description = "gallery-dl archive job for group '${name}'"; - After = [ "default.target" ]; - Documentation = "man:gallery-dl(1)"; - }; + systemd.user.services = lib.mapAttrs' (name: value: + lib.nameValuePair (jobUnitName name) { + Unit = { + Description = "gallery-dl archive job for group '${name}'"; + After = [ "default.target" ]; + Documentation = "man:gallery-dl(1)"; + }; - Service.ExecStart = - let - scriptName = "gallery-dl-service-${config.home.username}-${name}"; - jobSpecificSettingsFile = - settingsFormat.generate "gallery-dl-service-job-${name}-settings" - value.settings; - archiveScript = pkgs.writeShellScriptBin scriptName '' - ${cfg.package}/bin/gallery-dl ${ - lib.escapeShellArgs cfg.extraArgs - } ${ - lib.optionalString (cfg.settings != null) - "--config ${settingsFormatFile}" - } ${lib.escapeShellArgs value.extraArgs} ${ - lib.optionalString (value.settings != null) - "--config ${jobSpecificSettingsFile}" - } --destination ${cfg.archivePath} ${lib.escapeShellArgs value.urls} - ''; - in - "${archiveScript}/bin/${scriptName}"; - }) - cfg.jobs; + Service.ExecStart = let + scriptName = "gallery-dl-service-${config.home.username}-${name}"; + jobSpecificSettingsFile = + settingsFormat.generate "gallery-dl-service-job-${name}-settings" + value.settings; + archiveScript = pkgs.writeShellScriptBin scriptName '' + ${cfg.package}/bin/gallery-dl ${ + lib.escapeShellArgs cfg.extraArgs + } ${ + lib.optionalString (cfg.settings != null) + "--config ${settingsFormatFile}" + } ${lib.escapeShellArgs value.extraArgs} ${ + lib.optionalString (value.settings != null) + "--config ${jobSpecificSettingsFile}" + } --destination ${cfg.archivePath} ${lib.escapeShellArgs value.urls} + ''; + in "${archiveScript}/bin/${scriptName}"; + }) cfg.jobs; - systemd.user.timers = lib.mapAttrs' - (name: value: - lib.nameValuePair (jobUnitName name) { - Unit = { - Description = "gallery-dl archive job for group '${name}'"; - Documentation = "man:gallery-dl(1)"; - }; + systemd.user.timers = lib.mapAttrs' (name: value: + lib.nameValuePair (jobUnitName name) { + Unit = { + Description = "gallery-dl archive job for group '${name}'"; + Documentation = "man:gallery-dl(1)"; + }; - Timer = { - OnCalendar = value.startAt; - Persistent = value.persistent; - RandomizedDelaySec = "2min"; - }; + Timer = { + OnCalendar = value.startAt; + Persistent = value.persistent; + RandomizedDelaySec = "2min"; + }; - Install.WantedBy = [ "timers.target" ]; - }) - cfg.jobs; + Install.WantedBy = [ "timers.target" ]; + }) cfg.jobs; }; } diff --git a/modules/home-manager/services/gonic.nix b/modules/home-manager/services/gonic.nix index d135a3ad..8cf7df80 100644 --- a/modules/home-manager/services/gonic.nix +++ b/modules/home-manager/services/gonic.nix @@ -8,8 +8,7 @@ let listsAsDuplicateKeys = true; }; settingsFile = settingsFormat.generate "gonic-settings-config" cfg.settings; -in -{ +in { options.services.gonic = { enable = lib.mkEnableOption "Gonic, a Subsonic-compatible music server"; @@ -44,7 +43,8 @@ in }; Service = { - ExecStart = "${lib.getExe' cfg.package "gonic"} -config-path ${settingsFile}"; + ExecStart = + "${lib.getExe' cfg.package "gonic"} -config-path ${settingsFile}"; Restart = "on-failure"; }; diff --git a/modules/home-manager/services/ludusavi.nix b/modules/home-manager/services/ludusavi.nix index c5a07d38..444f4010 100644 --- a/modules/home-manager/services/ludusavi.nix +++ b/modules/home-manager/services/ludusavi.nix @@ -5,13 +5,11 @@ let settingsFormat = pkgs.formats.yaml { }; - configFile = - if cfg.configFile == null then - settingsFormat.generate "ludusavi-service-config" cfg.settings - else - cfg.configFile; -in -{ + configFile = if cfg.configFile == null then + settingsFormat.generate "ludusavi-service-config" cfg.settings + else + cfg.configFile; +in { options.services.ludusavi = { enable = lib.mkEnableOption "Ludusavi game backup"; @@ -40,11 +38,7 @@ in Extra arguments to be passed to the game backup service. ''; default = [ "--force" ]; - example = [ - "--force" - "--compression" "zstd" - "--compression-level" "13" - ]; + example = [ "--force" "--compression" "zstd" "--compression-level" "13" ]; }; startAt = lib.mkOption { @@ -73,7 +67,8 @@ in config = lib.mkIf cfg.enable { assertions = [ - (lib.hm.assertions.assertPlatform "services.ludusavi" pkgs lib.platforms.linux) + (lib.hm.assertions.assertPlatform "services.ludusavi" pkgs + lib.platforms.linux) ]; # We're putting it somewhere in the home directory instead of the typical @@ -86,14 +81,15 @@ in Description = "Periodic game backup"; Documentation = [ "https://github.com/mtkennerly/ludusavi" ]; - After = [ - "network-online.target" - "default.target" - ]; + After = [ "network-online.target" "default.target" ]; }; Service = { - ExecStart = "${lib.getExe' cfg.package "ludusavi"} --config ${config.xdg.dataHome}/ludusavi/hm-service-config.yaml backup ${lib.concatStringsSep " " cfg.extraArgs}"; + ExecStart = "${ + lib.getExe' cfg.package "ludusavi" + } --config ${config.xdg.dataHome}/ludusavi/hm-service-config.yaml backup ${ + lib.concatStringsSep " " cfg.extraArgs + }"; Restart = "on-failure"; }; }; diff --git a/modules/home-manager/services/matcha.nix b/modules/home-manager/services/matcha.nix index b7b81ee9..edf651be 100644 --- a/modules/home-manager/services/matcha.nix +++ b/modules/home-manager/services/matcha.nix @@ -5,8 +5,7 @@ let settingsFormat = pkgs.formats.yaml { }; settingsFile = settingsFormat.generate "matcha-config" cfg.settings; -in -{ +in { options.services.matcha = { enable = lib.mkEnableOption "Matcha periodic feed digest generator"; diff --git a/modules/home-manager/services/openrefine.nix b/modules/home-manager/services/openrefine.nix index 7324010f..5f6a1dac 100644 --- a/modules/home-manager/services/openrefine.nix +++ b/modules/home-manager/services/openrefine.nix @@ -4,8 +4,7 @@ let cfg = config.services.openrefine; settingsFormat = pkgs.formats.ini { }; -in -{ +in { options.services.openrefine = { enable = lib.mkEnableOption "OpenRefine server"; @@ -14,8 +13,7 @@ in settings = lib.mkOption { type = settingsFormat.type; default = { }; - example = lib.literalExpression '' - ''; + example = lib.literalExpression ""; }; extraFlags = lib.mkOption { @@ -35,15 +33,14 @@ in Description = "OpenRefine server"; Documentation = [ "https://openrefine.org/docs" ]; - After = [ - "network-online.target" - "default.target" - ]; + After = [ "network-online.target" "default.target" ]; }; Service = { ExecStart = '' - ${lib.getExe' cfg.package "refine"} ${lib.concatStringsSep " " cfg.extraFlags} + ${lib.getExe' cfg.package "refine"} ${ + lib.concatStringsSep " " cfg.extraFlags + } ''; Restart = "on-failure"; }; diff --git a/modules/home-manager/services/plover.nix b/modules/home-manager/services/plover.nix index 1f8b4d18..d48c6555 100644 --- a/modules/home-manager/services/plover.nix +++ b/modules/home-manager/services/plover.nix @@ -5,27 +5,26 @@ let toPloverINI = with lib; generators.toINI { - mkKeyValue = generators.mkKeyValueDefault - { - mkValueString = v: - if v == true then - "True" - else if v == false then - "False" - else - generators.mkValueStringDefault { } v; - } " = "; + mkKeyValue = generators.mkKeyValueDefault { + mkValueString = v: + if v == true then + "True" + else if v == false then + "False" + else + generators.mkValueStringDefault { } v; + } " = "; }; - ploverIniFormat = {}: { + ploverIniFormat = { }: { type = (pkgs.formats.ini { }).type; generate = name: value: pkgs.writeText name (toPloverINI value); }; settingsFormat = ploverIniFormat { }; - settingsFile = settingsFormat.generate "plover-config-${config.home.username}" cfg.settings; -in -{ + settingsFile = settingsFormat.generate "plover-config-${config.home.username}" + cfg.settings; +in { options.services.plover = { enable = lib.mkEnableOption "Plover stenography engine service"; @@ -43,20 +42,15 @@ in default = { }; defaultText = lib.literalExpression "{}"; example = { - "Output Configuration" = { - undo_levels = 100; - }; + "Output Configuration" = { undo_levels = 100; }; - "Stroke Display" = { - show = true; - }; + "Stroke Display" = { show = true; }; }; }; extraOptions = lib.mkOption { type = with lib.types; listOf str; - description = - "Extra command-line arguments to pass to {command}`plover`"; + description = "Extra command-line arguments to pass to {command}`plover`"; default = [ ]; defaultText = lib.literalExpression "[]"; example = lib.literalExpression '' @@ -73,7 +67,8 @@ in home.packages = [ cfg.package ]; - xdg.configFile."plover/plover.cfg".source = lib.mkIf (cfg.settings != { }) settingsFile; + xdg.configFile."plover/plover.cfg".source = + lib.mkIf (cfg.settings != { }) settingsFile; systemd.user.services.plover = { Unit = { @@ -82,7 +77,9 @@ in PartOf = "default.target"; }; - Service.ExecStart = "${lib.getExe' cfg.package "plover"} ${lib.concatStringsSep " " cfg.extraOptions}"; + Service.ExecStart = "${lib.getExe' cfg.package "plover"} ${ + lib.concatStringsSep " " cfg.extraOptions + }"; Install.WantedBy = [ "default.target" ]; }; diff --git a/modules/home-manager/services/yt-dlp.nix b/modules/home-manager/services/yt-dlp.nix index a0267b8f..ec87526c 100644 --- a/modules/home-manager/services/yt-dlp.nix +++ b/modules/home-manager/services/yt-dlp.nix @@ -60,15 +60,13 @@ let }; }; }; -in -{ +in { options.services.yt-dlp = { enable = lib.mkEnableOption "archiving service with yt-dlp"; package = lib.mkOption { type = lib.types.package; - description = - "The derivation that contains {command}`yt-dlp` binary."; + description = "The derivation that contains {command}`yt-dlp` binary."; default = pkgs.yt-dlp; defaultText = lib.literalExpression "pkgs.yt-dlp"; example = lib.literalExpression @@ -92,8 +90,7 @@ in extraArgs = lib.mkOption { type = with lib.types; listOf str; - description = - "List of arguments to be passed to {command}`yt-dlp`."; + description = "List of arguments to be passed to {command}`yt-dlp`."; default = [ "--download-archive '${cfg.archivePath}/download-list" ]; example = lib.literalExpression '' [ @@ -133,55 +130,51 @@ in }; config = lib.mkIf cfg.enable { - systemd.user.services = lib.mapAttrs' - (name: value: - lib.nameValuePair (jobUnitName name) { - Unit = { - Description = "yt-dlp archive job for group '${name}'"; - After = [ "default.target" ]; - Documentation = "man:yt-dlp(1)"; - }; + systemd.user.services = lib.mapAttrs' (name: value: + lib.nameValuePair (jobUnitName name) { + Unit = { + Description = "yt-dlp archive job for group '${name}'"; + After = [ "default.target" ]; + Documentation = "man:yt-dlp(1)"; + }; - Service = { - ExecStartPre = '' - ${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p ${ - lib.escapeShellArg cfg.archivePath - }" + Service = { + ExecStartPre = '' + ${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p ${ + lib.escapeShellArg cfg.archivePath + }" + ''; + ExecStart = let + scriptName = + "yt-dlp-archive-service-${config.home.username}-${name}"; + jobLevelArgs = lib.escapeShellArgs value.extraArgs; + urls = lib.escapeShellArgs value.urls; + archiveScript = pkgs.writeShellScriptBin scriptName '' + ${cfg.package}/bin/yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \ + ${urls} --paths ${ + lib.escapeShellArg cfg.archivePath + } ''; - ExecStart = - let - scriptName = - "yt-dlp-archive-service-${config.home.username}-${name}"; - jobLevelArgs = lib.escapeShellArgs value.extraArgs; - urls = lib.escapeShellArgs value.urls; - archiveScript = pkgs.writeShellScriptBin scriptName '' - ${cfg.package}/bin/yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \ - ${urls} --paths ${lib.escapeShellArg cfg.archivePath} - ''; - in - "${archiveScript}/bin/${scriptName}"; - StandardOutput = "journal"; - StandardError = "journal"; - }; - }) - cfg.jobs; + in "${archiveScript}/bin/${scriptName}"; + StandardOutput = "journal"; + StandardError = "journal"; + }; + }) cfg.jobs; - systemd.user.timers = lib.mapAttrs' - (name: value: - lib.nameValuePair (jobUnitName name) { - Unit = { - Description = "yt-dlp archive job for group '${name}'"; - Documentation = "man:yt-dlp(1)"; - }; + systemd.user.timers = lib.mapAttrs' (name: value: + lib.nameValuePair (jobUnitName name) { + Unit = { + Description = "yt-dlp archive job for group '${name}'"; + Documentation = "man:yt-dlp(1)"; + }; - Timer = { - OnCalendar = value.startAt; - RandomizedDelaySec = "2min"; - Persistent = value.persistent; - }; + Timer = { + OnCalendar = value.startAt; + RandomizedDelaySec = "2min"; + Persistent = value.persistent; + }; - Install.WantedBy = [ "timers.target" ]; - }) - cfg.jobs; + Install.WantedBy = [ "timers.target" ]; + }) cfg.jobs; }; } diff --git a/modules/nixos-generators/install-iso-graphical.nix b/modules/nixos-generators/install-iso-graphical.nix index 5f1bdf45..27f36069 100644 --- a/modules/nixos-generators/install-iso-graphical.nix +++ b/modules/nixos-generators/install-iso-graphical.nix @@ -10,8 +10,9 @@ ]; # override installation-cd-base and enable wpa and sshd start at boot - systemd.services.wpa_supplicant.wantedBy = lib.mkForce ["multi-user.target"]; - systemd.services.sshd.wantedBy = lib.mkForce ["multi-user.target"]; + systemd.services.wpa_supplicant.wantedBy = + lib.mkForce [ "multi-user.target" ]; + systemd.services.sshd.wantedBy = lib.mkForce [ "multi-user.target" ]; formatAttr = "isoImage"; fileExtension = ".iso"; diff --git a/modules/nixos/_private/extra-arguments.nix b/modules/nixos/_private/extra-arguments.nix index da8cb8bb..21700088 100644 --- a/modules/nixos/_private/extra-arguments.nix +++ b/modules/nixos/_private/extra-arguments.nix @@ -2,14 +2,18 @@ # system. { pkgs, lib, options, ... }: -let - foodogsquaredLib = import ../../../lib { inherit pkgs; }; -in -{ - _module.args.foodogsquaredLib = - foodogsquaredLib.extend (final: prev: { - nixos = import ../../../lib/env-specific/nixos.nix { inherit pkgs lib; self = final; }; - } // lib.optionalAttrs (options?sops) { - sops-nix = import ../../../lib/env-specific/sops.nix { inherit pkgs lib; self = final; }; +let foodogsquaredLib = import ../../../lib { inherit pkgs; }; +in { + _module.args.foodogsquaredLib = foodogsquaredLib.extend (final: prev: + { + nixos = import ../../../lib/env-specific/nixos.nix { + inherit pkgs lib; + self = final; + }; + } // lib.optionalAttrs (options ? sops) { + sops-nix = import ../../../lib/env-specific/sops.nix { + inherit pkgs lib; + self = final; + }; }); } diff --git a/modules/nixos/_private/shared-setups/server/crowdsec.nix b/modules/nixos/_private/shared-setups/server/crowdsec.nix index a4236d57..310a0020 100644 --- a/modules/nixos/_private/shared-setups/server/crowdsec.nix +++ b/modules/nixos/_private/shared-setups/server/crowdsec.nix @@ -1,9 +1,7 @@ { config, lib, pkgs, ... }: -let - cfg = config.shared-setups.server.crowdsec; -in -{ +let cfg = config.shared-setups.server.crowdsec; +in { options.shared-setups.server.crowdsec.enable = lib.mkEnableOption "typical Crowdsec setup for public-facing servers"; @@ -29,9 +27,7 @@ in dataSources = { ssh = lib.mkIf config.services.sshd.enable { source = "journalctl"; - journalctl_filter = [ - "_SYSTEMD_UNIT=ssh.service" - ]; + journalctl_filter = [ "_SYSTEMD_UNIT=ssh.service" ]; labels.type = "syslog"; }; }; diff --git a/modules/nixos/_private/shared-setups/server/default.nix b/modules/nixos/_private/shared-setups/server/default.nix index c1ae41c4..65e6160b 100644 --- a/modules/nixos/_private/shared-setups/server/default.nix +++ b/modules/nixos/_private/shared-setups/server/default.nix @@ -1,8 +1 @@ -{ - imports = [ - ./crowdsec.nix - ./fail2ban.nix - ./firewall.nix - ./nginx.nix - ]; -} +{ imports = [ ./crowdsec.nix ./fail2ban.nix ./firewall.nix ./nginx.nix ]; } diff --git a/modules/nixos/_private/shared-setups/server/fail2ban.nix b/modules/nixos/_private/shared-setups/server/fail2ban.nix index e8bd21f2..b2e06b4f 100644 --- a/modules/nixos/_private/shared-setups/server/fail2ban.nix +++ b/modules/nixos/_private/shared-setups/server/fail2ban.nix @@ -1,11 +1,9 @@ { config, lib, pkgs, ... }: -let - cfg = config.shared-setups.server.fail2ban; -in -{ - options.shared-setups.server.fail2ban.enable = - lib.mkEnableOption "typical fail2ban configuration for public-facing servers"; +let cfg = config.shared-setups.server.fail2ban; +in { + options.shared-setups.server.fail2ban.enable = lib.mkEnableOption + "typical fail2ban configuration for public-facing servers"; config = lib.mkIf cfg.enable { services.fail2ban = { diff --git a/modules/nixos/_private/shared-setups/server/firewall.nix b/modules/nixos/_private/shared-setups/server/firewall.nix index 3c1e6b28..5f3ab77a 100644 --- a/modules/nixos/_private/shared-setups/server/firewall.nix +++ b/modules/nixos/_private/shared-setups/server/firewall.nix @@ -1,10 +1,9 @@ { config, lib, pkgs, ... }: -let - cfg = config.shared-setups.server.firewall; -in -{ - options.shared-setups.server.firewall.enable = lib.mkEnableOption "typical firewall setup"; +let cfg = config.shared-setups.server.firewall; +in { + options.shared-setups.server.firewall.enable = + lib.mkEnableOption "typical firewall setup"; config = lib.mkIf cfg.enable { networking = { diff --git a/modules/nixos/_private/shared-setups/server/nginx.nix b/modules/nixos/_private/shared-setups/server/nginx.nix index 309d0812..8bef48d3 100644 --- a/modules/nixos/_private/shared-setups/server/nginx.nix +++ b/modules/nixos/_private/shared-setups/server/nginx.nix @@ -1,10 +1,8 @@ # The reverse proxy of choice. Logs should be rotated weekly. { config, lib, pkgs, ... }: -let - cfg = config.shared-setups.server.nginx; -in -{ +let cfg = config.shared-setups.server.nginx; +in { options.shared-setups.server.nginx.enable = lib.mkEnableOption "typical Nginx configuration for public-facing servers"; @@ -59,9 +57,7 @@ in extraConfig = '' zone services 64k; ''; - servers = { - "localhost:80" = { }; - }; + servers = { "localhost:80" = { }; }; }; }; diff --git a/modules/nixos/_private/state/default.nix b/modules/nixos/_private/state/default.nix index 35fad824..13f4b148 100644 --- a/modules/nixos/_private/state/default.nix +++ b/modules/nixos/_private/state/default.nix @@ -1,10 +1,7 @@ { lib, ... }: { - imports = [ - ./paths.nix - ./ports.nix - ]; + imports = [ ./paths.nix ./ports.nix ]; # We can basically dump everything that is supposed to hold values for the # entire system. This entry module should contain NOTHING ELSE! diff --git a/modules/nixos/_private/state/paths.nix b/modules/nixos/_private/state/paths.nix index 8ec32d6c..80ae4799 100644 --- a/modules/nixos/_private/state/paths.nix +++ b/modules/nixos/_private/state/paths.nix @@ -1,26 +1,23 @@ { lib, ... }: { - options.state = - let - directoriesSubmodule = { lib, ... }: { - options = { - paths = lib.mkOption { - type = with lib.types; attrsOf (either path (listOf str)); - description = '' - A set of directories to share its value to various parts of the - system. - ''; - default = { }; - example = { - cacheDir = "/var/cache"; - ignoreDirectories = [ "/var/log" ]; - ignoreFiles = [ "node_modules" ".gitignore" ".bak" ]; - }; + options.state = let + directoriesSubmodule = { lib, ... }: { + options = { + paths = lib.mkOption { + type = with lib.types; attrsOf (either path (listOf str)); + description = '' + A set of directories to share its value to various parts of the + system. + ''; + default = { }; + example = { + cacheDir = "/var/cache"; + ignoreDirectories = [ "/var/log" ]; + ignoreFiles = [ "node_modules" ".gitignore" ".bak" ]; }; }; }; - in lib.mkOption { - type = lib.types.submodule directoriesSubmodule; }; + in lib.mkOption { type = lib.types.submodule directoriesSubmodule; }; } diff --git a/modules/nixos/_private/state/ports.nix b/modules/nixos/_private/state/ports.nix index f8d4182a..cb16471d 100644 --- a/modules/nixos/_private/state/ports.nix +++ b/modules/nixos/_private/state/ports.nix @@ -44,66 +44,61 @@ let openFirewall = lib.mkEnableOption "opening the ports to firewall"; }; }; -in -{ - options.state = - let - portsModule = { lib, ... }: { - options = { - ports = lib.mkOption { - type = with lib.types; attrsOf (submodule portModule); - description = '' - A set of ports indicating what goes where in the NixOS system. - ''; - default = { }; - example = lib.literalExpression '' - rec { - gonic = { - value = 5757; - protocols = [ "tcp" ]; - openFirewall = true; - }; - uxplay = { - value = 7864; - openFirewall = true; - }; - uxplayClients.value = { - from = uxplay.value + 1; - to = uxplay.value + 20; - }; - } - ''; - }; +in { + options.state = let + portsModule = { lib, ... }: { + options = { + ports = lib.mkOption { + type = with lib.types; attrsOf (submodule portModule); + description = '' + A set of ports indicating what goes where in the NixOS system. + ''; + default = { }; + example = lib.literalExpression '' + rec { + gonic = { + value = 5757; + protocols = [ "tcp" ]; + openFirewall = true; + }; + uxplay = { + value = 7864; + openFirewall = true; + }; + uxplayClients.value = { + from = uxplay.value + 1; + to = uxplay.value + 20; + }; + } + ''; }; }; - in lib.mkOption { - type = lib.types.submodule portsModule; }; + in lib.mkOption { type = lib.types.submodule portsModule; }; config = lib.mkIf (cfg.ports != { }) { - networking.firewall = - let - allPortsToBeOpened = lib.filterAttrs (_: v: v.openFirewall) cfg.ports; - hasProtocol = protocol: v: lib.elem protocol v.protocols; - mkFirewallEntry = protocol: v: - let - inherit (v) value; - in - if lib.isAttrs value then { - ${if protocol == "tcp" - then "allowedTCPPortRanges" - else "allowedUDPPortRanges"} = [ value ]; - } else { - ${if protocol == "tcp" - then "allowedTCPPorts" - else "allowedUDPPorts"} = [ value ]; - }; + networking.firewall = let + allPortsToBeOpened = lib.filterAttrs (_: v: v.openFirewall) cfg.ports; + hasProtocol = protocol: v: lib.elem protocol v.protocols; + mkFirewallEntry = protocol: v: + let inherit (v) value; + in if lib.isAttrs value then { + ${ + if protocol == "tcp" then + "allowedTCPPortRanges" + else + "allowedUDPPortRanges" + } = [ value ]; + } else { + ${ + if protocol == "tcp" then "allowedTCPPorts" else "allowedUDPPorts" + } = [ value ]; + }; - mkFirewallEntryModule = _: v: - lib.optionalAttrs (hasProtocol "udp" v) (mkFirewallEntry "udp" v) - // lib.optionalAttrs (hasProtocol "tcp" v) (mkFirewallEntry "tcp" v); - in - lib.mkMerge - (lib.mapAttrsToList mkFirewallEntryModule allPortsToBeOpened); + mkFirewallEntryModule = _: v: + lib.optionalAttrs (hasProtocol "udp" v) (mkFirewallEntry "udp" v) + // lib.optionalAttrs (hasProtocol "tcp" v) (mkFirewallEntry "tcp" v); + in lib.mkMerge + (lib.mapAttrsToList mkFirewallEntryModule allPortsToBeOpened); }; } diff --git a/modules/nixos/_private/suites/browsers.nix b/modules/nixos/_private/suites/browsers.nix index 667d3205..8470e5f9 100644 --- a/modules/nixos/_private/suites/browsers.nix +++ b/modules/nixos/_private/suites/browsers.nix @@ -3,10 +3,8 @@ # "enterprise" is for all of the users which is me, myself, and I). { config, lib, pkgs, ... }: -let - cfg = config.suites.browsers; -in -{ +let cfg = config.suites.browsers; +in { options.suites.browsers = { firefox.enable = lib.mkEnableOption "Firefox and its fixed configuration"; chromium.enable = lib.mkEnableOption "Chromium and its fixed configuration"; @@ -14,9 +12,7 @@ in config = lib.mkMerge [ (lib.mkIf cfg.chromium.enable { - environment.systemPackages = with pkgs; [ - chromium - ]; + environment.systemPackages = with pkgs; [ chromium ]; programs.chromium = { enable = true; @@ -49,12 +45,8 @@ in AppAutoUpdate = false; Containers.Default = - let - mkContainer = name: color: icon: { - inherit name color icon; - }; - in - [ + let mkContainer = name: color: icon: { inherit name color icon; }; + in [ (mkContainer "Personal" "blue" "fingerprint") (mkContainer "Self-hosted" "pink" "fingerprint") (mkContainer "Work" "red" "briefcase") @@ -69,42 +61,47 @@ in DisableSetDesktopBackground = true; DontCheckDefaultBrowser = true; - ExtensionSettings = - let - mozillaAddon = id: "https://addons.mozilla.org/firefox/downloads/latest/${id}/latest.xpi"; + ExtensionSettings = let + mozillaAddon = id: + "https://addons.mozilla.org/firefox/downloads/latest/${id}/latest.xpi"; - # Unlike the user-specific browser configuration, we're just - # considering the bare minimum set of preferred extensions. - extensions = { - "@contain-facebook".install_url = mozillaAddon "facebook-container"; - "@contain-google".install_url = mozillaAddon "google-container"; - "@testpilot-containers".install_url = mozillaAddon "multi-account-containers"; - "{446900e4-71c2-419f-a6a7-df9c091e268b}" = { - install_url = mozillaAddon "bitwarden-password-manager"; - installation_mode = "force_installed"; - default_area = "navbar"; - }; - "ff2mpv@yossarian.net" = { - install_url = mozillaAddon "ff2mpv"; - default_area = "navbar"; - }; - "firefox-translations-addon@mozilla.org".install_url = mozillaAddon "firefox-translations"; - "jid1-MnnxcxisBPnSXQ@jetpack".install_url = mozillaAddon "privacy-badger17"; - "tridactyl.vim@cmcaine.co.uk".install_url = mozillaAddon "tridactyl-vim"; - "uBlock0@raymondhill.net".install_url = mozillaAddon "ublock-origin"; - "wayback_machine@mozilla.org" = { - install_url = mozillaAddon "wayback-machine_new"; - default_area = "navbar"; - }; + # Unlike the user-specific browser configuration, we're just + # considering the bare minimum set of preferred extensions. + extensions = { + "@contain-facebook".install_url = + mozillaAddon "facebook-container"; + "@contain-google".install_url = mozillaAddon "google-container"; + "@testpilot-containers".install_url = + mozillaAddon "multi-account-containers"; + "{446900e4-71c2-419f-a6a7-df9c091e268b}" = { + install_url = mozillaAddon "bitwarden-password-manager"; + installation_mode = "force_installed"; + default_area = "navbar"; }; + "ff2mpv@yossarian.net" = { + install_url = mozillaAddon "ff2mpv"; + default_area = "navbar"; + }; + "firefox-translations-addon@mozilla.org".install_url = + mozillaAddon "firefox-translations"; + "jid1-MnnxcxisBPnSXQ@jetpack".install_url = + mozillaAddon "privacy-badger17"; + "tridactyl.vim@cmcaine.co.uk".install_url = + mozillaAddon "tridactyl-vim"; + "uBlock0@raymondhill.net".install_url = + mozillaAddon "ublock-origin"; + "wayback_machine@mozilla.org" = { + install_url = mozillaAddon "wayback-machine_new"; + default_area = "navbar"; + }; + }; - applyInstallationMode = name: value: - lib.nameValuePair name (value // - (lib.optionalAttrs - (! (lib.hasAttrByPath [ "installation_mode" ] value)) - { installation_mode = "normal_installed"; })); - in - lib.mapAttrs' applyInstallationMode extensions; + applyInstallationMode = name: value: + lib.nameValuePair name (value // (lib.optionalAttrs + (!(lib.hasAttrByPath [ "installation_mode" ] value)) { + installation_mode = "normal_installed"; + })); + in lib.mapAttrs' applyInstallationMode extensions; FirefoxHome = { Highlights = false; @@ -116,9 +113,7 @@ in NoDefaultBookmarks = true; OfferToSaveLoginsDefault = false; PasswordManagerEnabled = false; - SanitizeOnShutdown = { - FormData = true; - }; + SanitizeOnShutdown = { FormData = true; }; SearchEngines = { Add = [ @@ -126,16 +121,20 @@ in Name = "Brave"; URLTemplate = "https://search.brave.com/search?q={searchTerms}"; Method = "GET"; - IconURL = "https://brave.com/static-assets/images/brave-favicon.png"; + IconURL = + "https://brave.com/static-assets/images/brave-favicon.png"; Alias = "brave"; - SuggestURLTemplate = "https://search.brave.com/api/suggest?q={searchTerms}"; + SuggestURLTemplate = + "https://search.brave.com/api/suggest?q={searchTerms}"; } { Name = "nixpkgs"; - URLTemplate = "https://search.nixos.org/packages?type=packages&query={searchTerms}"; + URLTemplate = + "https://search.nixos.org/packages?type=packages&query={searchTerms}"; Method = "GET"; - IconURL = "file://${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + IconURL = + "file://${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; } ]; Default = "Brave"; diff --git a/modules/nixos/_private/suites/desktop.nix b/modules/nixos/_private/suites/desktop.nix index a0722e8f..3acbc4c9 100644 --- a/modules/nixos/_private/suites/desktop.nix +++ b/modules/nixos/_private/suites/desktop.nix @@ -8,8 +8,10 @@ in { options.suites.desktop = { enable = lib.mkEnableOption "basic desktop-related services and default programs"; - cleanup.enable = lib.mkEnableOption "activation of various cleanup services"; - autoUpgrade.enable = lib.mkEnableOption "auto-upgrade service with this system"; + cleanup.enable = + lib.mkEnableOption "activation of various cleanup services"; + autoUpgrade.enable = + lib.mkEnableOption "auto-upgrade service with this system"; }; config = lib.mkIf cfg.enable (lib.mkMerge [ @@ -18,33 +20,29 @@ in { services.flatpak.enable = true; xdg.portal.enable = true; - environment.etc = - let - urls = { - "flathub" = { - url = "https://flathub.org/repo/flathub.flatpakrepo"; - hash = "sha256-M3HdJQ5h2eFjNjAHP+/aFTzUQm9y9K+gwzc64uj+oDo="; - }; - "flathub-beta" = { - url = "https://flathub.org/beta-repo/flathub-beta.flatpakrepo"; - hash = "sha256-WCyuPJ+dRjnwJ976/m+jO9oKOk1EEpDZJq2For4PcgY="; - }; - "gnome-nightly" = { - url = "https://nightly.gnome.org/gnome-nightly.flatpakrepo"; - hash = "sha256-rFluVpCvgs1iy7YKVnkPh3p6YuF4orbVuOhLUUFRyYM="; - }; - "kdeapps" = { - url = "https://distribute.kde.org/kdeapps.flatpakrepo"; - hash = "sha256-dCF9QQYMmqMuzwAS+HYoPAAtwfzO7aVCl8s4RwhneqI="; - }; + environment.etc = let + urls = { + "flathub" = { + url = "https://flathub.org/repo/flathub.flatpakrepo"; + hash = "sha256-M3HdJQ5h2eFjNjAHP+/aFTzUQm9y9K+gwzc64uj+oDo="; }; - in - lib.mapAttrs' - (name: remote: - lib.nameValuePair - "flatpak/remotes.d/${name}.flatpakrepo" - { source = pkgs.fetchurl remote; }) - urls; + "flathub-beta" = { + url = "https://flathub.org/beta-repo/flathub-beta.flatpakrepo"; + hash = "sha256-WCyuPJ+dRjnwJ976/m+jO9oKOk1EEpDZJq2For4PcgY="; + }; + "gnome-nightly" = { + url = "https://nightly.gnome.org/gnome-nightly.flatpakrepo"; + hash = "sha256-rFluVpCvgs1iy7YKVnkPh3p6YuF4orbVuOhLUUFRyYM="; + }; + "kdeapps" = { + url = "https://distribute.kde.org/kdeapps.flatpakrepo"; + hash = "sha256-dCF9QQYMmqMuzwAS+HYoPAAtwfzO7aVCl8s4RwhneqI="; + }; + }; + in lib.mapAttrs' (name: remote: + lib.nameValuePair "flatpak/remotes.d/${name}.flatpakrepo" { + source = pkgs.fetchurl remote; + }) urls; programs.extra-container.enable = true; @@ -54,50 +52,44 @@ in { # Run unpatched binaries with these! programs.nix-ld = { enable = true; - libraries = - let - xorgLibs = with pkgs.xorg; [ - libX11 - libXScrnSaver - libXcomposite - libXcursor - libXdamage - libXext - libXfixes - libXi - libXrandr - libXrender - libXtst - libxcb - libxkbfile - libxshmfence - ]; - commonLibs = with pkgs; [ - alsa-lib - cairo - freetype - dbus - icu - libGL - libnotify - mesa - nss - pango - pipewire - ]; - desktopLibs = with pkgs; [ - qt5.full - qt6.full - gtk3 - gtk4 - ]; - in - commonLibs ++ xorgLibs ++ desktopLibs; + libraries = let + xorgLibs = with pkgs.xorg; [ + libX11 + libXScrnSaver + libXcomposite + libXcursor + libXdamage + libXext + libXfixes + libXi + libXrandr + libXrender + libXtst + libxcb + libxkbfile + libxshmfence + ]; + commonLibs = with pkgs; [ + alsa-lib + cairo + freetype + dbus + icu + libGL + libnotify + mesa + nss + pango + pipewire + ]; + desktopLibs = with pkgs; [ qt5.full qt6.full gtk3 gtk4 ]; + in commonLibs ++ xorgLibs ++ desktopLibs; }; - environment.systemPackages = with pkgs; [ - steam-run # For the heathens that still uses FHS. - ]; + environment.systemPackages = with pkgs; + [ + steam-run # For the heathens that still uses FHS. + ]; # Enable running GNOME apps outside GNOME. programs.dconf.enable = true; diff --git a/modules/nixos/_private/suites/dev.nix b/modules/nixos/_private/suites/dev.nix index 995d3e5b..ca9094e1 100644 --- a/modules/nixos/_private/suites/dev.nix +++ b/modules/nixos/_private/suites/dev.nix @@ -6,7 +6,8 @@ in { options.suites.dev = { enable = lib.mkEnableOption "basic configuration for software development"; extras.enable = lib.mkEnableOption "additional shell utilities"; - hardware.enable = lib.mkEnableOption "additional hardware-related dev utilities"; + hardware.enable = + lib.mkEnableOption "additional hardware-related dev utilities"; security.enable = lib.mkEnableOption "additional security-oriented tools"; containers.enable = lib.mkEnableOption "containers setup"; virtual-machines.enable = lib.mkEnableOption "virtual machines setup"; @@ -69,32 +70,33 @@ in { } (lib.mkIf cfg.extras.enable { - environment.systemPackages = with pkgs; [ - bandwhich # Sniffing your packets. - cachix # Compile no more by using someone's binary cache! - direnv # The power of local development environment. - difftastic # Cracked version of diff. - lazygit # Git interface for the lazy. - lazydocker # Git interface for the lazy. - fd # Oh nice, a more reliable `find`. - ripgrep # On nice, a more reliable `grep`. - eza # Oh nice, a shinier `ls`. - bat # dog > sky dog > cat - fzf # A fuzzy finder that enables fuzzy finding not furry finding, a common misconception. - quilt # Patching right up yer' alley. - zoxide # Gain teleportation abilities! - ] - # Finally, a local environment for testing out GitHub workflows without - # embarassing yourself pushing a bunch of commits. - ++ (lib.optional config.virtualisation.docker.enable pkgs.act) + environment.systemPackages = with pkgs; + [ + bandwhich # Sniffing your packets. + cachix # Compile no more by using someone's binary cache! + direnv # The power of local development environment. + difftastic # Cracked version of diff. + lazygit # Git interface for the lazy. + lazydocker # Git interface for the lazy. + fd # Oh nice, a more reliable `find`. + ripgrep # On nice, a more reliable `grep`. + eza # Oh nice, a shinier `ls`. + bat # dog > sky dog > cat + fzf # A fuzzy finder that enables fuzzy finding not furry finding, a common misconception. + quilt # Patching right up yer' alley. + zoxide # Gain teleportation abilities! + ] + # Finally, a local environment for testing out GitHub workflows without + # embarassing yourself pushing a bunch of commits. + ++ (lib.optional config.virtualisation.docker.enable pkgs.act) - # Enable all of the gud things. - ++ (lib.optionals config.programs.git.enable (with pkgs; [ - tea # Make some Tea... - hut # ...in the Hut... - github-cli # ...in the Git Hub... - git-filter-repo # History is written by the victors (and force-pushers which are surely not victors). - ])); + # Enable all of the gud things. + ++ (lib.optionals config.programs.git.enable (with pkgs; [ + tea # Make some Tea... + hut # ...in the Hut... + github-cli # ...in the Git Hub... + git-filter-repo # History is written by the victors (and force-pushers which are surely not victors). + ])); # Make per-project devenvs more of a living thing. services.lorri.enable = true; @@ -152,7 +154,8 @@ in { "/nix/store:/nix/store:r" "/etc/profiles/per-user:/etc/profiles/per-user:r" ]; - container_image_default = "registry.opensuse.org/opensuse/distrobox-packaging:latest"; + container_image_default = + "registry.opensuse.org/opensuse/distrobox-packaging:latest"; container_command = "sh -norc"; }; }; @@ -165,20 +168,14 @@ in { enable = true; dates = "weekly"; }; - defaultNetwork.settings = { - dns_enabled = true; - }; + defaultNetwork.settings = { dns_enabled = true; }; }; # Enable usual containers configuration. virtualisation.containers = { enable = true; - registries.search = [ - "docker.io" - "ghcr.io" - "quay.io" - "registry.opensuse.org" - ]; + registries.search = + [ "docker.io" "ghcr.io" "quay.io" "registry.opensuse.org" ]; }; }) @@ -203,7 +200,6 @@ in { # Easier, better, faster, stronger. programs.neovim = { enable = true; - defaultEditor = true; withNodeJs = true; withRuby = true; }; diff --git a/modules/nixos/_private/suites/filesystem.nix b/modules/nixos/_private/suites/filesystem.nix index b5bd10b2..005113c8 100644 --- a/modules/nixos/_private/suites/filesystem.nix +++ b/modules/nixos/_private/suites/filesystem.nix @@ -8,17 +8,18 @@ # the filesystems' respective manual pages. { config, lib, pkgs, ... }: -let - cfg = config.suites.filesystem; -in -{ +let cfg = config.suites.filesystem; +in { options.suites.filesystem = { tools.enable = lib.mkEnableOption "filesystem-related settings"; setups = { archive.enable = lib.mkEnableOption "automounting offline archive"; - external-hdd.enable = lib.mkEnableOption "automounting personal external hard drive"; - personal-webstorage.enable = lib.mkEnableOption "automounting of personal WebDAV directory"; - laptop-ssd.enable = lib.mkEnableOption "automounting a leftover laptop SSD"; + external-hdd.enable = + lib.mkEnableOption "automounting personal external hard drive"; + personal-webstorage.enable = + lib.mkEnableOption "automounting of personal WebDAV directory"; + laptop-ssd.enable = + lib.mkEnableOption "automounting a leftover laptop SSD"; }; }; @@ -28,10 +29,7 @@ in services.davfs2.enable = true; # Installing filesystem debugging utilities. - environment.systemPackages = with pkgs; [ - afuse - ntfs3g - ]; + environment.systemPackages = with pkgs; [ afuse ntfs3g ]; }) (lib.mkIf cfg.setups.archive.enable { @@ -63,7 +61,8 @@ in state.paths.external-hdd = "/media/external-storage"; fileSystems."${config.state.paths.external-hdd}" = { - device = lib.mkDefault "/dev/disk/by-partlabel/disk-live-installer-root"; + device = + lib.mkDefault "/dev/disk/by-partlabel/disk-live-installer-root"; fsType = "btrfs"; noCheck = true; options = lib.mkDefault [ diff --git a/modules/nixos/_private/suites/gaming.nix b/modules/nixos/_private/suites/gaming.nix index f2a3f8c0..31fb2644 100644 --- a/modules/nixos/_private/suites/gaming.nix +++ b/modules/nixos/_private/suites/gaming.nix @@ -1,15 +1,16 @@ # NixOS gaming. { lib, config, pkgs, ... }: -let - cfg = config.suites.gaming; -in -{ +let cfg = config.suites.gaming; +in { options.suites.gaming = { enable = lib.mkEnableOption "basic gaming setup"; - emulators.enable = lib.mkEnableOption "installation of individual game emulators"; - retro-computing.enable = lib.mkEnableOption "installation of retro computer systems"; - games.enable = lib.mkEnableOption "installation of certain FOSS games for funsies"; + emulators.enable = + lib.mkEnableOption "installation of individual game emulators"; + retro-computing.enable = + lib.mkEnableOption "installation of retro computer systems"; + games.enable = + lib.mkEnableOption "installation of certain FOSS games for funsies"; }; # Just don't ask where you can sail getting the games. :) @@ -19,12 +20,7 @@ in # initializing sessions. programs.retroarch = { enable = true; - cores = with pkgs.libretro; [ - bsnes-hd - desmume - dosbox-pure - ppsspp - ]; + cores = with pkgs.libretro; [ bsnes-hd desmume dosbox-pure ppsspp ]; }; # Setup the go-to platform for Linux gaming. Most of the diff --git a/modules/nixos/_private/suites/i18n.nix b/modules/nixos/_private/suites/i18n.nix index 926cfb1b..3c6d4766 100644 --- a/modules/nixos/_private/suites/i18n.nix +++ b/modules/nixos/_private/suites/i18n.nix @@ -3,10 +3,8 @@ # this module will stay aiming for desktop. { config, lib, pkgs, ... }: -let - cfg = config.suites.i18n; -in -{ +let cfg = config.suites.i18n; +in { options.suites.i18n = { enable = lib.mkEnableOption "main i18n config"; setup = lib.mkOption { @@ -45,9 +43,7 @@ in ]; } - (lib.mkIf (cfg.setup != null) { - i18n.inputMethod.enable = true; - }) + (lib.mkIf (cfg.setup != null) { i18n.inputMethod.enable = true; }) (lib.mkIf (cfg.setup == "ibus") { i18n.inputMethod = { diff --git a/modules/nixos/_private/suites/server.nix b/modules/nixos/_private/suites/server.nix index 1ebf51cb..b3478d7d 100644 --- a/modules/nixos/_private/suites/server.nix +++ b/modules/nixos/_private/suites/server.nix @@ -3,10 +3,8 @@ # between them. { config, lib, pkgs, ... }: -let - cfg = config.suites.server; -in -{ +let cfg = config.suites.server; +in { options.suites.server = { enable = lib.mkEnableOption "server-related settings"; cleanup.enable = lib.mkEnableOption "cleanup service for the system"; @@ -16,8 +14,8 @@ in config = lib.mkIf cfg.enable (lib.mkMerge [ { assertions = lib.singleton { - assertion = - !config.suites.desktop.enable || !config.suites.server.enable; + assertion = !config.suites.desktop.enable + || !config.suites.server.enable; message = '' Desktop profile is also enabled. The profiles `desktop` and `server` are mutually exclusive. diff --git a/modules/nixos/_private/suites/vpn.nix b/modules/nixos/_private/suites/vpn.nix index 2d5291cf..023c9b58 100644 --- a/modules/nixos/_private/suites/vpn.nix +++ b/modules/nixos/_private/suites/vpn.nix @@ -1,11 +1,10 @@ { config, lib, pkgs, ... }: -let - cfg = config.suites.vpn; -in -{ +let cfg = config.suites.vpn; +in { options.suites.vpn = { - personal.enable = lib.mkEnableOption "personal VPN configuration with Wireguard"; + personal.enable = + lib.mkEnableOption "personal VPN configuration with Wireguard"; }; config = lib.mkMerge [ diff --git a/modules/nixos/_private/workflows/a-happy-gnome/default.nix b/modules/nixos/_private/workflows/a-happy-gnome/default.nix index 54dc6fab..28cbd374 100644 --- a/modules/nixos/_private/workflows/a-happy-gnome/default.nix +++ b/modules/nixos/_private/workflows/a-happy-gnome/default.nix @@ -4,15 +4,14 @@ let workflowName = "a-happy-gnome"; cfg = config.workflows.workflows.${workflowName}; - requiredApps = with pkgs; [ - # The application menu. - junction - ]; -in -{ - options.workflows.enable = lib.mkOption { - type = with lib.types; listOf (enum [ workflowName ]); - }; + requiredApps = with pkgs; + [ + # The application menu. + junction + ]; +in { + options.workflows.enable = + lib.mkOption { type = with lib.types; listOf (enum [ workflowName ]); }; options.workflows.workflows.${workflowName} = { shellExtensions = lib.mkOption { @@ -66,6 +65,7 @@ in dconf-editor # A saner version of Windows registry. kando gnome-boxes # Virtual machines, son. + mission-center # It is your duty to monitor your system. polari # Your gateway to one of the most hidden and cobweb-ridden parts of the internet. ;) gradience # Make it rain! handbrake # Take a break from those custom ffmpeg conversion scripts. @@ -76,7 +76,7 @@ in gnome-backgrounds # Default backgrounds. gnome-menus # It is required for custom menus in extensions. - gnome-extension-manager # The cooler GNOME extensions app. + #gnome-extension-manager # The cooler GNOME extensions app. gnome-search-provider-recoll # This is here for some reason. # Nautilus extensions @@ -89,9 +89,8 @@ in }; disableSearchProviders = lib.mkOption { - type = with lib.types; listOf ( - coercedTo str (lib.removeSuffix ".desktop") str - ); + type = with lib.types; + listOf (coercedTo str (lib.removeSuffix ".desktop") str); description = '' A list of the application filenames (without the `.desktop` part) where its GNOME Shell search provider is to be disabled. @@ -171,7 +170,8 @@ in disabled = cfg.disableSearchProviders; }; "org/gnome/shell" = { - enabled-extensions = builtins.map (p: p.extensionUuid) cfg.shellExtensions; + enabled-extensions = + builtins.map (p: p.extensionUuid) cfg.shellExtensions; }; } @@ -180,8 +180,9 @@ in (lib.pipe cfg.disableNotifications [ (builtins.map (app: lib.nameValuePair - "org/gnome/desktop/notifications/application/${app}" - { show-banners = false; })) + "org/gnome/desktop/notifications/application/${app}" { + show-banners = false; + })) lib.listToAttrs ]) @@ -204,6 +205,7 @@ in }; }; - environment.systemPackages = requiredApps ++ cfg.shellExtensions ++ cfg.extraApps; + environment.systemPackages = requiredApps ++ cfg.shellExtensions + ++ cfg.extraApps; }; } diff --git a/modules/nixos/_private/workflows/default.nix b/modules/nixos/_private/workflows/default.nix index 6a11779f..133fe109 100644 --- a/modules/nixos/_private/workflows/default.nix +++ b/modules/nixos/_private/workflows/default.nix @@ -20,15 +20,8 @@ tmux configuration where it can be used inside of a TTY or something like that. ''; - example = [ - "a-happy-gnome" - "knome" - "horizontal-hunger" - ]; + example = [ "a-happy-gnome" "knome" "horizontal-hunger" ]; }; - imports = [ - ./a-happy-gnome - ./knome - ]; + imports = [ ./a-happy-gnome ./knome ]; } diff --git a/modules/nixos/_private/workflows/horizontal-hunger/default.nix b/modules/nixos/_private/workflows/horizontal-hunger/default.nix index 27753d3f..b44e0635 100644 --- a/modules/nixos/_private/workflows/horizontal-hunger/default.nix +++ b/modules/nixos/_private/workflows/horizontal-hunger/default.nix @@ -19,11 +19,9 @@ let name = "${workflowId}-env"; paths = requiredPackages ++ cfg.extraApps; }; -in -{ - options.workflows.enable = lib.mkOption { - type = with lib.types; listOf (enum [ workflowId ]); - }; +in { + options.workflows.enable = + lib.mkOption { type = with lib.types; listOf (enum [ workflowId ]); }; options.workflows.workflows.${workflowId} = { package = lib.mkOption { @@ -37,11 +35,7 @@ in extraApps = lib.mkOption { type = with lib.types; listOf package; - default = with pkgs; [ - flowtime - dialect - blanket - ]; + default = with pkgs; [ flowtime dialect blanket ]; description = '' A list of extraneous applications to be included with the desktop session. @@ -78,26 +72,23 @@ in # For now, the portal configuration doesn't work since Niri is now # hardcoded to set the apprioriate envs for portal component. It is # considered broken (or rather unused) for now. - xdg.portal = - lib.mkMerge [ - { - enable = lib.mkDefault true; - extraPortals = [ - pkgs.xdg-desktop-portal-gtk - ]; + xdg.portal = lib.mkMerge [ + { + enable = lib.mkDefault true; + extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; - # The option value is only a coerced `lib.type.str` so ehhh... - config.${workflowId}.default = - [ "gtk" ] - ++ lib.optionals (config.services.gnome.gnome-keyring.enable) [ "gnome" ]; - } + # The option value is only a coerced `lib.type.str` so ehhh... + config.${workflowId}.default = [ "gtk" ] + ++ lib.optionals (config.services.gnome.gnome-keyring.enable) + [ "gnome" ]; + } - (lib.mkIf config.services.gnome.gnome-keyring.enable { - config.${workflowId} = { - "org.freedesktop.impl.portal.Secret" = "gnome-keyring"; - }; - }) - ]; + (lib.mkIf config.services.gnome.gnome-keyring.enable { + config.${workflowId} = { + "org.freedesktop.impl.portal.Secret" = "gnome-keyring"; + }; + }) + ]; # Install of the programs. environment.systemPackages = requiredPackages ++ cfg.extraApps; @@ -107,18 +98,21 @@ in fullName = "Horizontal Hunger"; desktopNames = [ workflowId ]; - systemd.targetUnit = - let - requiredComponents = [ "window-manager" ]; - getId = lib.foldlAttrs (acc: _: v: acc ++ [ "${v.id}.target" ]) [ ]; - in { - requires = getId (lib.filterAttrs (n: _: lib.elem n requiredComponents) sessionConfig.components); - wants = getId (lib.attrsets.removeAttrs sessionConfig.components requiredComponents); - }; + systemd.targetUnit = let + requiredComponents = [ "window-manager" ]; + getId = lib.foldlAttrs (acc: _: v: acc ++ [ "${v.id}.target" ]) [ ]; + in { + requires = getId (lib.filterAttrs (n: _: lib.elem n requiredComponents) + sessionConfig.components); + wants = getId (lib.attrsets.removeAttrs sessionConfig.components + requiredComponents); + }; components = { window-manager = { - script = "${lib.getExe' cfg.package "niri"} --config /tmp/shared/modules/nixos/_private/workflows/horizontal-hunger/config/niri/config"; + script = "${ + lib.getExe' cfg.package "niri" + } --config /tmp/shared/modules/nixos/_private/workflows/horizontal-hunger/config/niri/config"; description = "Window manager"; systemd.serviceUnit = { @@ -144,7 +138,9 @@ in }; desktop-widgets = { - script = "${lib.getExe' pkgs.ags "ags"} --config /tmp/shared/modules/nixos/_private/workflows/horizontal-hunger/config/ags/config.js"; + script = "${ + lib.getExe' pkgs.ags "ags" + } --config /tmp/shared/modules/nixos/_private/workflows/horizontal-hunger/config/ags/config.js"; description = "Desktop widgets"; systemd.serviceUnit = { @@ -167,7 +163,8 @@ in }; auth-agent = { - script = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; + script = + "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; description = "Authentication agent"; systemd.serviceUnit = { diff --git a/modules/nixos/_private/workflows/knome/default.nix b/modules/nixos/_private/workflows/knome/default.nix index 11bf9623..748e746b 100644 --- a/modules/nixos/_private/workflows/knome/default.nix +++ b/modules/nixos/_private/workflows/knome/default.nix @@ -3,11 +3,9 @@ let workflowName = "knome"; cfg = config.workflows.workflows.${workflowName}; -in -{ - options.workflows.enable = lib.mkOption { - type = with lib.types; listOf (enum [ workflowName ]); - }; +in { + options.workflows.enable = + lib.mkOption { type = with lib.types; listOf (enum [ workflowName ]); }; config = lib.mkIf (lib.elem workflowName config.workflows.enable) { services.xserver = { @@ -66,21 +64,23 @@ in "xdg/khotkeysrc".source = ./config/kde/khotkeysrc; "xdg/klaunchrc".source = ./config/kde/klaunchrc; "xdg/krunnerrc".source = ./config/kde/krunnerrc; - "xdg/plasma-org.kde.plasma.desktop-appletsrc".source = ./config/kde/plasma-org.kde.plasma.desktop-appletsrc; + "xdg/plasma-org.kde.plasma.desktop-appletsrc".source = + ./config/kde/plasma-org.kde.plasma.desktop-appletsrc; "xdg/plasmanotifyrc".source = ./config/kde/plasmanotifyrc; "xdg/plasmarc".source = ./config/kde/plasmarc; }; # Install additional packages. - environment.systemPackages = with pkgs; [ - kitty # The preferred terminal emulator. - ] ++ (with pkgs.plasma5Packages; [ - bismuth # Tiling inside Plasma? + environment.systemPackages = with pkgs; + [ + kitty # The preferred terminal emulator. + ] ++ (with pkgs.plasma5Packages; [ + bismuth # Tiling inside Plasma? - # Powering up Krunner. - krunner-symbols - krunner-ssh - ]); + # Powering up Krunner. + krunner-symbols + krunner-ssh + ]); programs.kdeconnect.enable = true; }; diff --git a/modules/nixos/profiles/desktop/default.nix b/modules/nixos/profiles/desktop/default.nix index 2219df0d..42a83a6f 100644 --- a/modules/nixos/profiles/desktop/default.nix +++ b/modules/nixos/profiles/desktop/default.nix @@ -2,9 +2,5 @@ # here should be enough in common to the typical desktop setups found on # non-NixOS systems. { - imports = [ - ./fonts.nix - ./audio.nix - ./hardware.nix - ]; + imports = [ ./fonts.nix ./audio.nix ./hardware.nix ]; } diff --git a/modules/nixos/profiles/generic.nix b/modules/nixos/profiles/generic.nix index f5b7c4a6..ae3ad077 100644 --- a/modules/nixos/profiles/generic.nix +++ b/modules/nixos/profiles/generic.nix @@ -25,11 +25,9 @@ # Append with the default time servers. It is becoming more unresponsive as # of 2023-10-28. - networking.timeServers = [ - "europe.pool.ntp.org" - "asia.pool.ntp.org" - "time.cloudflare.com" - ] ++ options.networking.timeServers.default; + networking.timeServers = + [ "europe.pool.ntp.org" "asia.pool.ntp.org" "time.cloudflare.com" ] + ++ options.networking.timeServers.default; # Disable channel state files. This shouldn't break any existing # programs as long as we manage them NIX_PATH ourselves. diff --git a/modules/nixos/profiles/hardened.nix b/modules/nixos/profiles/hardened.nix index dd12ab82..9c24d6c5 100644 --- a/modules/nixos/profiles/hardened.nix +++ b/modules/nixos/profiles/hardened.nix @@ -3,9 +3,7 @@ { pkgs, lib, modulesPath, ... }: { - imports = [ - "${modulesPath}/profiles/hardened.nix" - ]; + imports = [ "${modulesPath}/profiles/hardened.nix" ]; # Don't replace it mid-way! DON'T TURN LEFT!!!! security.protectKernelImage = true; diff --git a/modules/nixos/profiles/headless.nix b/modules/nixos/profiles/headless.nix index f73099bf..454372b7 100644 --- a/modules/nixos/profiles/headless.nix +++ b/modules/nixos/profiles/headless.nix @@ -4,9 +4,7 @@ { lib, modulesPath, ... }: { - imports = [ - "${modulesPath}/profiles/headless.nix" - ]; + imports = [ "${modulesPath}/profiles/headless.nix" ]; # Bluetooth is so 2000s, my wireless earbuds are scratching all to hell. hardware.bluetooth.enable = lib.mkDefault false; diff --git a/modules/nixos/profiles/hetzner-cloud-cx22.nix b/modules/nixos/profiles/hetzner-cloud-cx22.nix index c96eb7fa..c378cf0a 100644 --- a/modules/nixos/profiles/hetzner-cloud-cx22.nix +++ b/modules/nixos/profiles/hetzner-cloud-cx22.nix @@ -1,9 +1,7 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = [ - (modulesPath + "/profiles/qemu-guest.nix") - ]; + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; # Hetzner can only support non-UEFI bootloader (or at least it doesn't with # systemd-boot). @@ -13,12 +11,14 @@ efiInstallAsRemovable = true; }; - boot.initrd.availableKernelModules = [ "ata_piix" "virtio_pci" "virtio_scsi" "xhci_pci" "sd_mod" "sr_mod" ]; + boot.initrd.availableKernelModules = + [ "ata_piix" "virtio_pci" "virtio_scsi" "xhci_pci" "sd_mod" "sr_mod" ]; boot.initrd.kernelModules = [ "nvme" ]; zramSwap.enable = true; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.intel.updateMicrocode = + lib.mkDefault config.hardware.enableRedistributableFirmware; services.qemuGuest.enable = true; systemd.services.qemu-guest-agent.path = [ pkgs.shadow ]; diff --git a/modules/nixos/profiles/installer.nix b/modules/nixos/profiles/installer.nix index 752261d3..ef9438c5 100644 --- a/modules/nixos/profiles/installer.nix +++ b/modules/nixos/profiles/installer.nix @@ -11,15 +11,8 @@ ]; # Include some modern niceties. - environment.systemPackages = with pkgs; [ - curl - disko - ripgrep - git - lazygit - neovim - zellij - ] ++ foodogsquaredLib.stdenv; + environment.systemPackages = with pkgs; + [ curl disko ripgrep git lazygit neovim zellij ] ++ foodogsquaredLib.stdenv; # Yeah, that's right, this is also a Guix System installer because SCREW YOU, # NIXOS USERS! diff --git a/modules/nixos/profiles/nix-conf.nix b/modules/nixos/profiles/nix-conf.nix index 15c6cd60..fa41a439 100644 --- a/modules/nixos/profiles/nix-conf.nix +++ b/modules/nixos/profiles/nix-conf.nix @@ -20,9 +20,9 @@ # # Since we're using flakes to make this possible, we need it. Plus, the # UX of Nix CLI is becoming closer to Guix's which is a nice bonus. - experimental-features = - [ "nix-command" "flakes" ] - ++ lib.optionals (lib.versionOlder config.nix.package.version "2.22.0") [ "repl-flake" ]; + experimental-features = [ "nix-command" "flakes" ] + ++ lib.optionals (lib.versionOlder config.nix.package.version "2.22.0") + [ "repl-flake" ]; auto-optimise-store = lib.mkDefault true; # We don't want to download every time we invoke Nix, seriously. Thanks. diff --git a/modules/nixos/programs/blender.nix b/modules/nixos/programs/blender.nix index 56abcdfc..a2743432 100644 --- a/modules/nixos/programs/blender.nix +++ b/modules/nixos/programs/blender.nix @@ -3,18 +3,13 @@ let cfg = config.programs.blender; - addons = - let - blenderVersion = lib.versions.majorMinor cfg.package.version; - in - pkgs.symlinkJoin { - name = "blender-${blenderVersion}-addons"; - paths = let - _paths = cfg.addons ++ [ cfg.package ]; - in lib.concatMap (p: [ "${p}/share/blender" ]) _paths; - }; -in -{ + addons = let blenderVersion = lib.versions.majorMinor cfg.package.version; + in pkgs.symlinkJoin { + name = "blender-${blenderVersion}-addons"; + paths = let _paths = cfg.addons ++ [ cfg.package ]; + in lib.concatMap (p: [ "${p}/share/blender" ]) _paths; + }; +in { options.programs.blender = { enable = lib.mkEnableOption "Blender, a 3D computer graphics tool"; @@ -51,6 +46,7 @@ in # on `/usr/share/blender/$MAJOR.$MINOR`, we'll have to modify it with an # environment variable. This means in a NixOS system, it is only expected # to have one instance of the system resources. - environment.sessionVariables.BLENDER_SYSTEM_RESOURCES = lib.mkIf (builtins.length cfg.addons > 0) addons; + environment.sessionVariables.BLENDER_SYSTEM_RESOURCES = + lib.mkIf (builtins.length cfg.addons > 0) addons; }; } diff --git a/modules/nixos/programs/distrobox.nix b/modules/nixos/programs/distrobox.nix index db86768f..bb1443a8 100644 --- a/modules/nixos/programs/distrobox.nix +++ b/modules/nixos/programs/distrobox.nix @@ -8,33 +8,30 @@ let # values with shell expansions. toDistroboxConf = lib.generators.toKeyValue { listsAsDuplicateKeys = false; - mkKeyValue = lib.generators.mkKeyValueDefault - { - mkValueString = v: - if v == true then "1" - else if v == false then "0" - else if lib.isString v then ''"${v}"'' - else if lib.isPath v then lib.escapeShellArg v - else if lib.isList v then ''"${lib.concatStringsSep " " v}"'' - else lib.generators.mkValueStringDefault { } v; - } "="; + mkKeyValue = lib.generators.mkKeyValueDefault { + mkValueString = v: + if v == true then + "1" + else if v == false then + "0" + else if lib.isString v then + ''"${v}"'' + else if lib.isPath v then + lib.escapeShellArg v + else if lib.isList v then + ''"${lib.concatStringsSep " " v}"'' + else + lib.generators.mkValueStringDefault { } v; + } "="; }; - distroboxConf = {}: { + distroboxConf = { }: { type = with lib.types; let - valueType = (oneOf [ - bool - float - int - path - str - (listOf valueType) - ]) // { + valueType = (oneOf [ bool float int path str (listOf valueType) ]) // { description = "Distrobox settings value"; }; - in - attrsOf valueType; + in attrsOf valueType; generate = name: value: pkgs.writeText name (toDistroboxConf value); }; @@ -45,8 +42,7 @@ let ${toDistroboxConf cfg.settings} ${cfg.extraConfig} ''; -in -{ +in { options.programs.distrobox = { enable = lib.mkEnableOption "Distrobox"; diff --git a/modules/nixos/programs/gnome-session/default.nix b/modules/nixos/programs/gnome-session/default.nix index 32eef757..0efffb4d 100644 --- a/modules/nixos/programs/gnome-session/default.nix +++ b/modules/nixos/programs/gnome-session/default.nix @@ -15,99 +15,84 @@ let glibKeyfileFormat = { type = with lib.types; let - valueType = oneOf [ - bool - float - int - str - (listOf valueType) - ] // { - description = "GLib keyfile atom (bool, int, float, string, or a list of the previous atoms)"; + valueType = oneOf [ bool float int str (listOf valueType) ] // { + description = + "GLib keyfile atom (bool, int, float, string, or a list of the previous atoms)"; }; - in - attrsOf (attrsOf valueType); + in attrsOf (attrsOf valueType); generate = name: value: - pkgs.callPackage ({ writeText }: - writeText name (lib.generators.toDconfINI value)); + pkgs.callPackage + ({ writeText }: writeText name (lib.generators.toDconfINI value)); }; # The bulk of the work. Pretty much the main purpose of this module. - sessionPackages = lib.mapAttrsToList - (_: session: - let - gnomeSession = glibKeyfileFormat.generate "session-${session.name}" session.settings; + sessionPackages = lib.mapAttrsToList (_: session: + let + gnomeSession = + glibKeyfileFormat.generate "session-${session.name}" session.settings; - # For now, we set this as a static template since there's not much - # things to configure especially for a desktop session anyways. - displaySession = '' - [Desktop Entry] - Name=${session.fullName} - Comment=${session.description} - Exec="@out@/libexec/${session.name}-session" - Type=Application - DesktopNames=${lib.concatStringsSep ";" session.desktopNames} - ''; + # For now, we set this as a static template since there's not much + # things to configure especially for a desktop session anyways. + displaySession = '' + [Desktop Entry] + Name=${session.fullName} + Comment=${session.description} + Exec="@out@/libexec/${session.name}-session" + Type=Application + DesktopNames=${lib.concatStringsSep ";" session.desktopNames} + ''; - # Similarly to the desktop session template, this is also set as a - # static template. - sessionScript = '' - #!${pkgs.runtimeShell} + # Similarly to the desktop session template, this is also set as a + # static template. + sessionScript = '' + #!${pkgs.runtimeShell} - # gnome-session is also looking for RequiredComponents in here. - XDG_CONFIG_DIRS=@out@/etc/xdg''${XDG_CONFIG_DIRS:-:$XDG_CONFIG_DIRS} + # gnome-session is also looking for RequiredComponents in here. + XDG_CONFIG_DIRS=@out@/etc/xdg''${XDG_CONFIG_DIRS:-:$XDG_CONFIG_DIRS} - # We'll have to force gnome-session to detect our session. - XDG_DATA_DIRS=@out@/share''${XDG_DATA_DIRS:-:$XDG_DATA_DIRS} + # We'll have to force gnome-session to detect our session. + XDG_DATA_DIRS=@out@/share''${XDG_DATA_DIRS:-:$XDG_DATA_DIRS} - ${lib.getExe' cfg.package "gnome-session"} ${lib.escapeShellArgs session.extraArgs} - ''; - - installDesktopFiles = - lib.mapAttrsToList - (name: component: - let - desktopPackage = pkgs.makeDesktopItem component.desktopConfig; - in - '' - install -Dm0644 ${desktopPackage}/share/applications/*.desktop -t $out/share/applications - '') - session.components; - in - pkgs.runCommand "${session.name}-desktop-session-files" - { - env = { - inherit (session) fullName; - }; - inherit displaySession gnomeSession sessionScript; - passAsFile = [ "displaySession" "sessionScript" ]; - passthru.providedSessions = [ session.name ]; + ${lib.getExe' cfg.package "gnome-session"} ${ + lib.escapeShellArgs session.extraArgs } - '' - SESSION_SCRIPT="$out/libexec/${session.name}-session" - install -Dm0755 "$sessionScriptPath" "$SESSION_SCRIPT" - substituteAllInPlace "$SESSION_SCRIPT" + ''; - GNOME_SESSION_FILE="$out/share/gnome-session/sessions/${session.name}.session" - install -Dm0644 "$gnomeSession" "$GNOME_SESSION_FILE" + installDesktopFiles = lib.mapAttrsToList (name: component: + let desktopPackage = pkgs.makeDesktopItem component.desktopConfig; + in '' + install -Dm0644 ${desktopPackage}/share/applications/*.desktop -t $out/share/applications + '') session.components; + in pkgs.runCommand "${session.name}-desktop-session-files" { + env = { inherit (session) fullName; }; + inherit displaySession gnomeSession sessionScript; + passAsFile = [ "displaySession" "sessionScript" ]; + passthru.providedSessions = [ session.name ]; + } '' + SESSION_SCRIPT="$out/libexec/${session.name}-session" + install -Dm0755 "$sessionScriptPath" "$SESSION_SCRIPT" + substituteAllInPlace "$SESSION_SCRIPT" - DISPLAY_SESSION_FILE="$out/share/wayland-sessions/${session.name}.desktop" - install -Dm0644 "$displaySessionPath" "$DISPLAY_SESSION_FILE" - substituteAllInPlace "$DISPLAY_SESSION_FILE" + GNOME_SESSION_FILE="$out/share/gnome-session/sessions/${session.name}.session" + install -Dm0644 "$gnomeSession" "$GNOME_SESSION_FILE" - ${lib.concatStringsSep "\n" installDesktopFiles} - '' - ) - cfg.sessions; + DISPLAY_SESSION_FILE="$out/share/wayland-sessions/${session.name}.desktop" + install -Dm0644 "$displaySessionPath" "$DISPLAY_SESSION_FILE" + substituteAllInPlace "$DISPLAY_SESSION_FILE" - sessionSystemdUnits = lib.concatMapAttrs - (_: session: - let - inherit (utils.systemdUtils.lib) - pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit; + ${lib.concatStringsSep "\n" installDesktopFiles} + '') cfg.sessions; - mkSystemdUnits = name: component: { - "${component.id}.service" = serviceToUnit component.systemd.serviceUnit; + sessionSystemdUnits = lib.concatMapAttrs (_: session: + let + inherit (utils.systemdUtils.lib) + pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit; + + mkSystemdUnits = name: component: + { + "${component.id}.service" = + serviceToUnit component.systemd.serviceUnit; "${component.id}.target" = targetToUnit component.systemd.targetUnit; } // lib.optionalAttrs (component.systemd.socketUnit != null) { "${component.id}.socket" = socketToUnit component.systemd.socketUnit; @@ -117,15 +102,12 @@ let "${component.id}.path" = pathToUnit component.systemd.pathUnit; }; - componentsUnits = lib.concatMapAttrs mkSystemdUnits session.components; - in - componentsUnits // { - "gnome-session@${session.name}.target" = targetToUnit session.systemd.targetUnit; - } - ) - cfg.sessions; -in -{ + componentsUnits = lib.concatMapAttrs mkSystemdUnits session.components; + in componentsUnits // { + "gnome-session@${session.name}.target" = + targetToUnit session.systemd.targetUnit; + }) cfg.sessions; +in { options.programs.gnome-session = { package = lib.mkOption { type = lib.types.package; @@ -139,11 +121,12 @@ in }; sessions = lib.mkOption { - type = with lib.types; attrsOf (submoduleWith { - specialArgs = { inherit utils glibKeyfileFormat pkgs; }; - modules = [ ./submodules/session-type.nix ]; - shorthandOnlyDefinesConfig = true; - }); + type = with lib.types; + attrsOf (submoduleWith { + specialArgs = { inherit utils glibKeyfileFormat pkgs; }; + modules = [ ./submodules/session-type.nix ]; + shorthandOnlyDefinesConfig = true; + }); description = '' A set of desktop sessions to be created with {manpage}`gnome-session(1)`. This gnome-session configuration generates diff --git a/modules/nixos/programs/gnome-session/submodules/component-type.nix b/modules/nixos/programs/gnome-session/submodules/component-type.nix index dd5dbbc5..5db6a890 100644 --- a/modules/nixos/programs/gnome-session/submodules/component-type.nix +++ b/modules/nixos/programs/gnome-session/submodules/component-type.nix @@ -1,9 +1,7 @@ { name, config, pkgs, lib, utils, session, ... }: let - optionalSystemdUnitOption = { - unitType, systemdModuleAttribute, otherType, - }: + optionalSystemdUnitOption = { unitType, systemdModuleAttribute, otherType, }: lib.mkOption { type = lib.types.nullOr otherType; description = '' @@ -20,8 +18,7 @@ let visible = "shallow"; default = null; }; -in -{ +in { options = { name = lib.mkOption { type = lib.types.nonEmptyStr; @@ -81,17 +78,16 @@ in # NixOS systemd extensions as much as possible. For more details, see # `config` attribute of the `sessionType`. serviceUnit = lib.mkOption { - type = - let - inherit (utils.systemdUtils.lib) unitConfig serviceConfig; - inherit (utils.systemdUtils.unitOptions) commonUnitOptions serviceOptions; - in - lib.types.submodule [ - commonUnitOptions - serviceOptions - serviceConfig - unitConfig - ]; + type = let + inherit (utils.systemdUtils.lib) unitConfig serviceConfig; + inherit (utils.systemdUtils.unitOptions) + commonUnitOptions serviceOptions; + in lib.types.submodule [ + commonUnitOptions + serviceOptions + serviceConfig + unitConfig + ]; description = '' systemd service configuration to be generated. This should be configured if the session is managed by systemd. @@ -114,15 +110,10 @@ in }; targetUnit = lib.mkOption { - type = - let - inherit (utils.systemdUtils.lib) unitConfig; - inherit (utils.systemdUtils.unitOptions) commonUnitOptions; - in - lib.types.submodule [ - commonUnitOptions - unitConfig - ]; + type = let + inherit (utils.systemdUtils.lib) unitConfig; + inherit (utils.systemdUtils.unitOptions) commonUnitOptions; + in lib.types.submodule [ commonUnitOptions unitConfig ]; description = '' systemd target configuration to be generated. This should be configured if the session is managed by systemd. @@ -143,46 +134,31 @@ in timerUnit = optionalSystemdUnitOption { unitType = "timer"; systemdModuleAttribute = "timers"; - otherType = - let - inherit (utils.systemdUtils.unitOptions) timerOptions commonUnitOptions; - inherit (utils.systemdUtils.lib) unitConfig; - in - lib.types.submodule [ - commonUnitOptions - timerOptions - unitConfig - ]; + otherType = let + inherit (utils.systemdUtils.unitOptions) + timerOptions commonUnitOptions; + inherit (utils.systemdUtils.lib) unitConfig; + in lib.types.submodule [ commonUnitOptions timerOptions unitConfig ]; }; socketUnit = optionalSystemdUnitOption { unitType = "socket"; systemdModuleAttribute = "sockets"; - otherType = - let - inherit (utils.systemdUtils.unitOptions) socketOptions commonUnitOptions; - inherit (utils.systemdUtils.lib) unitConfig; - in - lib.types.submodule [ - commonUnitOptions - socketOptions - unitConfig - ]; + otherType = let + inherit (utils.systemdUtils.unitOptions) + socketOptions commonUnitOptions; + inherit (utils.systemdUtils.lib) unitConfig; + in lib.types.submodule [ commonUnitOptions socketOptions unitConfig ]; }; pathUnit = optionalSystemdUnitOption { unitType = "path"; systemdModuleAttribute = "paths"; - otherType = - let - inherit (utils.systemdUtils.unitOptions) pathOptions commonUnitOptions; - inherit (utils.systemdUtils.lib) unitConfig; - in - lib.types.submodule [ - commonUnitOptions - pathOptions - unitConfig - ]; + otherType = let + inherit (utils.systemdUtils.unitOptions) + pathOptions commonUnitOptions; + inherit (utils.systemdUtils.lib) unitConfig; + in lib.types.submodule [ commonUnitOptions pathOptions unitConfig ]; }; }; @@ -204,7 +180,9 @@ in desktopConfig = { name = lib.mkForce config.id; desktopName = lib.mkDefault "${session.fullName} - ${config.description}"; - exec = lib.mkDefault (pkgs.writeShellScript "${session.name}-${config.name}-script" config.script); + exec = lib.mkDefault + (pkgs.writeShellScript "${session.name}-${config.name}-script" + config.script); noDisplay = lib.mkForce true; onlyShowIn = session.desktopNames; @@ -219,32 +197,31 @@ in }; }; - /* - Setting some recommendation and requirements for systemd-managed - gnome-session components. Note there are the missing directives that - COULD include some sane defaults here. + /* Setting some recommendation and requirements for systemd-managed + gnome-session components. Note there are the missing directives that + COULD include some sane defaults here. - * The `Unit.OnFailure=` and `Unit.OnFailureJobMode=` directives. Since - different components don't have the same priority and don't handle - failures the same way, we didn't set it here. This is on the user to - know how different desktop components interact with each other - especially if one of them failed. + * The `Unit.OnFailure=` and `Unit.OnFailureJobMode=` directives. Since + different components don't have the same priority and don't handle + failures the same way, we didn't set it here. This is on the user to + know how different desktop components interact with each other + especially if one of them failed. - * Even if we have a way to limit starting desktop components with - `systemd-xdg-autostart-condition`, using `Service.ExecCondition=` would - severely limit possible reuse of desktop components with other - NixOS-module-generated gnome-session sessions so we're not bothering with - those. + * Even if we have a way to limit starting desktop components with + `systemd-xdg-autostart-condition`, using `Service.ExecCondition=` would + severely limit possible reuse of desktop components with other + NixOS-module-generated gnome-session sessions so we're not bothering with + those. - * `Service.Type=` is obviously not included since not all desktop - components are the same either. Some of them could be a D-Bus service, - some of them are oneshots, etc. Though, it might be better to have this - as an explicit option set by the user instead of setting `Type=notify` as - a default. + * `Service.Type=` is obviously not included since not all desktop + components are the same either. Some of them could be a D-Bus service, + some of them are oneshots, etc. Though, it might be better to have this + as an explicit option set by the user instead of setting `Type=notify` as + a default. - * Most sandboxing options. Aside from the fact we're dealing with a - systemd user unit, much of them are unnecessary and rarely needed (if - ever like `Service.PrivateTmp=`?) so we didn't set such defaults here. + * Most sandboxing options. Aside from the fact we're dealing with a + systemd user unit, much of them are unnecessary and rarely needed (if + ever like `Service.PrivateTmp=`?) so we didn't set such defaults here. */ systemd.serviceUnit = { script = lib.mkAfter config.script; @@ -283,15 +260,14 @@ in }; }; - /* - Take note, we'll assume the session target unit will be the one to set - the dependency-related directives (i.e., `After=`, `Before=`, `Requires=`) - so no need to set any in here. + /* Take note, we'll assume the session target unit will be the one to set + the dependency-related directives (i.e., `After=`, `Before=`, `Requires=`) + so no need to set any in here. - And another thing, we didn't set a default value for dependency-related - directives to one of the gnome-session-specific target unit. It is more - likely for a user to design their own desktop session with full control - so it would be better for these options to be empty for less confusion. + And another thing, we didn't set a default value for dependency-related + directives to one of the gnome-session-specific target unit. It is more + likely for a user to design their own desktop session with full control + so it would be better for these options to be empty for less confusion. */ systemd.targetUnit = { # This should be the dependency-related directive to be configured. The @@ -299,10 +275,7 @@ in wants = [ "${config.id}.service" ]; description = lib.mkDefault config.description; - documentation = [ - "man:gnome-session(1)" - "man:systemd.special(7)" - ]; + documentation = [ "man:gnome-session(1)" "man:systemd.special(7)" ]; # Similar to the service unit, this is very much required as noted from # the `gnome-session(1)` manual page. diff --git a/modules/nixos/programs/gnome-session/submodules/session-type.nix b/modules/nixos/programs/gnome-session/submodules/session-type.nix index 93a85e24..401875df 100644 --- a/modules/nixos/programs/gnome-session/submodules/session-type.nix +++ b/modules/nixos/programs/gnome-session/submodules/session-type.nix @@ -25,8 +25,7 @@ let "Endless" "Old" ]; -in -{ +in { options = { name = lib.mkOption { type = lib.types.nonEmptyStr; @@ -68,13 +67,11 @@ in default = [ config.fullName ]; defaultText = "[ .fullName ]"; apply = names: - builtins.map - (name: - if (lib.elem name validDesktopNames) || (lib.hasPrefix "X-" name) then - name - else - "X-${name}") - names; + builtins.map (name: + if (lib.elem name validDesktopNames) || (lib.hasPrefix "X-" name) then + name + else + "X-${name}") names; example = [ "GNOME" "Garden" ]; }; @@ -84,22 +81,24 @@ in A one-sentence description of the desktop environment. ''; default = "${config.fullName} desktop environment"; - defaultText = lib.literalExpression "\${.fullName} desktop environment"; + defaultText = + lib.literalExpression "\${.fullName} desktop environment"; example = "A desktop environment featuring a scrolling compositor."; }; components = lib.mkOption { - type = with lib.types; attrsOf (submoduleWith { - specialArgs = { - inherit utils pkgs; - session = { - inherit (config) fullName desktopNames description; - inherit name; + type = with lib.types; + attrsOf (submoduleWith { + specialArgs = { + inherit utils pkgs; + session = { + inherit (config) fullName desktopNames description; + inherit name; + }; }; - }; - modules = [ ./component-type.nix ]; - shorthandOnlyDefinesConfig = true; - }); + modules = [ ./component-type.nix ]; + shorthandOnlyDefinesConfig = true; + }); description = '' The individual components to be launched with the desktop session. ''; @@ -131,10 +130,7 @@ in configuration. ::: ''; - example = [ - "--systemd" - "--disable-acceleration-check" - ]; + example = [ "--systemd" "--disable-acceleration-check" ]; }; settings = lib.mkOption { @@ -175,7 +171,8 @@ in customized version of GNOME. ::: ''; - default = lib.mapAttrsToList (_: component: component.id) config.components; + default = + lib.mapAttrsToList (_: component: component.id) config.components; example = [ "org.gnome.Shell" "org.gnome.SettingsDaemon.A11ySettings" @@ -186,15 +183,10 @@ in systemd = { targetUnit = lib.mkOption { - type = - let - inherit (utils.systemdUtils.lib) unitConfig; - inherit (utils.systemdUtils.unitOptions) commonUnitOptions; - in - lib.types.submodule [ - commonUnitOptions - unitConfig - ]; + type = let + inherit (utils.systemdUtils.lib) unitConfig; + inherit (utils.systemdUtils.unitOptions) commonUnitOptions; + in lib.types.submodule [ commonUnitOptions unitConfig ]; description = '' systemd target configuration to be generated for `gnome-session@.target`. This should be configured if the @@ -229,7 +221,8 @@ in systemd.targetUnit = { overrideStrategy = lib.mkForce "asDropin"; - wants = lib.mkDefault (builtins.map (c: "${c}.target") config.requiredComponents); + wants = lib.mkDefault + (builtins.map (c: "${c}.target") config.requiredComponents); }; settings."GNOME Session" = { diff --git a/modules/nixos/programs/pop-launcher.nix b/modules/nixos/programs/pop-launcher.nix index 3de4e16f..632801cf 100644 --- a/modules/nixos/programs/pop-launcher.nix +++ b/modules/nixos/programs/pop-launcher.nix @@ -9,8 +9,7 @@ let name = "pop-launcher-plugins-system"; paths = builtins.map (p: "${p}/share/pop-launcher") cfg.plugins; }; -in -{ +in { options.programs.pop-launcher = { enable = lib.mkOption { description = '' diff --git a/modules/nixos/programs/retroarch.nix b/modules/nixos/programs/retroarch.nix index a8d7992f..cba8ecef 100644 --- a/modules/nixos/programs/retroarch.nix +++ b/modules/nixos/programs/retroarch.nix @@ -3,11 +3,8 @@ let cfg = config.programs.retroarch; - finalPkg = pkgs.wrapRetroArch { - inherit (cfg) cores settings; - }; -in -{ + finalPkg = pkgs.wrapRetroArch { inherit (cfg) cores settings; }; +in { options.programs.retroarch = { enable = lib.mkEnableOption "configuring Retroarch"; @@ -43,7 +40,5 @@ in }; }; - config = lib.mkIf cfg.enable { - environment.systemPackages = [ finalPkg ]; - }; + config = lib.mkIf cfg.enable { environment.systemPackages = [ finalPkg ]; }; } diff --git a/modules/nixos/programs/sessiond/default.nix b/modules/nixos/programs/sessiond/default.nix index 38c51af4..174db73a 100644 --- a/modules/nixos/programs/sessiond/default.nix +++ b/modules/nixos/programs/sessiond/default.nix @@ -3,49 +3,43 @@ let cfg = config.programs.sessiond; - sessionPackages = lib.mapAttrsToList - (_: session: - let - displaySession = '' - [Desktop Entry] - Name=${session.fullName} - Comment=${session.description} - Exec="@out@/libexec/${session.name}-session" - Type=Application - DesktopNames=${lib.concatStringsSep ";" session.desktopNames}; - ''; + sessionPackages = lib.mapAttrsToList (_: session: + let + displaySession = '' + [Desktop Entry] + Name=${session.fullName} + Comment=${session.description} + Exec="@out@/libexec/${session.name}-session" + Type=Application + DesktopNames=${lib.concatStringsSep ";" session.desktopNames}; + ''; - sessionScript = '' - #!${pkgs.runtimeShell} + sessionScript = '' + #!${pkgs.runtimeShell} - ${lib.getExe' cfg.package "sessionctl"} run "${session.name}.target" - ''; - in - pkgs.runCommandLocal "${session.name}-desktop-session-files" + ${lib.getExe' cfg.package "sessionctl"} run "${session.name}.target" + ''; + in pkgs.runCommandLocal "${session.name}-desktop-session-files" { + inherit displaySession sessionScript; + passAsFile = [ "displaySession" "sessionScript" ]; + passthru.providedSessions = [ session.name ]; + } '' + SESSION_SCRIPT="$out/libexec/${session.name}-session" + install -Dm0755 "$sessionScriptPath" "$SESSION_SCRIPT" + substituteAllInPlace "$SESSION_SCRIPT" + + DISPLAY_SESSION_FILE="$out/share/xsessions/${session.name}.desktop" + install -Dm0644 "$displaySessionPath" "$DISPLAY_SESSION_FILE" + substituteAllInPlace "$DISPLAY_SESSION_FILE" + '') cfg.sessions; + + sessionSystemdUnits = lib.concatMapAttrs (name: session: + let + inherit (utils.systemdUtils.lib) + pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit; + + mkSystemdUnits = name: component: { - inherit displaySession sessionScript; - passAsFile = [ "displaySession" "sessionScript" ]; - passthru.providedSessions = [ session.name ]; - } - '' - SESSION_SCRIPT="$out/libexec/${session.name}-session" - install -Dm0755 "$sessionScriptPath" "$SESSION_SCRIPT" - substituteAllInPlace "$SESSION_SCRIPT" - - DISPLAY_SESSION_FILE="$out/share/xsessions/${session.name}.desktop" - install -Dm0644 "$displaySessionPath" "$DISPLAY_SESSION_FILE" - substituteAllInPlace "$DISPLAY_SESSION_FILE" - '' - ) - cfg.sessions; - - sessionSystemdUnits = lib.concatMapAttrs - (name: session: - let - inherit (utils.systemdUtils.lib) - pathToUnit serviceToUnit targetToUnit timerToUnit socketToUnit; - - mkSystemdUnits = name: component: { "${component.id}.service" = serviceToUnit component.serviceUnit; "${component.id}.target" = targetToUnit component.targetUnit; } // lib.optionalAttrs (component.socketUnit != null) { @@ -56,17 +50,12 @@ let "${component.id}.path" = pathToUnit component.pathUnit; }; - sessionComponents = - lib.concatMapAttrs mkSystemdUnits session.components; - in - sessionComponents // { - "${session.name}.service" = serviceToUnit session.serviceUnit; - "${session.name}.target" = targetToUnit session.targetUnit; - } - ) - cfg.sessions; -in -{ + sessionComponents = lib.concatMapAttrs mkSystemdUnits session.components; + in sessionComponents // { + "${session.name}.service" = serviceToUnit session.serviceUnit; + "${session.name}.target" = targetToUnit session.targetUnit; + }) cfg.sessions; +in { options.programs.sessiond = { package = lib.mkOption { type = lib.types.package; @@ -80,13 +69,14 @@ in }; sessions = lib.mkOption { - type = with lib.types; attrsOf (submoduleWith { - specialArgs = { - inherit utils pkgs; - sessiondPkg = cfg.package; - }; - modules = [ ./submodules/session-type.nix ]; - }); + type = with lib.types; + attrsOf (submoduleWith { + specialArgs = { + inherit utils pkgs; + sessiondPkg = cfg.package; + }; + modules = [ ./submodules/session-type.nix ]; + }); example = lib.literalExpression '' { "com.example.Beepeedobolyuessemm" = { diff --git a/modules/nixos/programs/sessiond/submodules/component-type.nix b/modules/nixos/programs/sessiond/submodules/component-type.nix index 297de0f7..51c25832 100644 --- a/modules/nixos/programs/sessiond/submodules/component-type.nix +++ b/modules/nixos/programs/sessiond/submodules/component-type.nix @@ -16,8 +16,7 @@ let visible = "shallow"; default = null; }; -in -{ +in { options = { name = lib.mkOption { type = lib.types.nonEmptyStr; @@ -36,17 +35,16 @@ in # NixOS systemd extensions as much as possible. For more details, see # `config` attribute of the `sessionType`. serviceUnit = lib.mkOption { - type = - let - inherit (utils.systemdUtils.lib) unitConfig serviceConfig; - inherit (utils.systemdUtils.unitOptions) commonUnitOptions serviceOptions; - in - lib.types.submodule [ - commonUnitOptions - serviceOptions - serviceConfig - unitConfig - ]; + type = let + inherit (utils.systemdUtils.lib) unitConfig serviceConfig; + inherit (utils.systemdUtils.unitOptions) + commonUnitOptions serviceOptions; + in lib.types.submodule [ + commonUnitOptions + serviceOptions + serviceConfig + unitConfig + ]; description = '' systemd service configuration to be generated. This should be configured if the session is managed by systemd. @@ -66,15 +64,10 @@ in }; targetUnit = lib.mkOption { - type = - let - inherit (utils.systemdUtils.lib) unitConfig; - inherit (utils.systemdUtils.unitOptions) commonUnitOptions; - in - lib.types.submodule [ - commonUnitOptions - unitConfig - ]; + type = let + inherit (utils.systemdUtils.lib) unitConfig; + inherit (utils.systemdUtils.unitOptions) commonUnitOptions; + in lib.types.submodule [ commonUnitOptions unitConfig ]; description = '' systemd target configuration to be generated. This is generated by default alongside the service where it is configured to be a part of @@ -90,42 +83,28 @@ in }; timerUnit = optionalSystemdUnitOption "timer" "timers" // { - type = - let - inherit (utils.systemdUtils.unitOptions) timerOptions commonUnitOptions; - inherit (utils.systemdUtils.lib) unitConfig; - in - with lib.types; nullOr (submodule [ - commonUnitOptions - timerOptions - unitConfig - ]); + type = let + inherit (utils.systemdUtils.unitOptions) timerOptions commonUnitOptions; + inherit (utils.systemdUtils.lib) unitConfig; + in with lib.types; + nullOr (submodule [ commonUnitOptions timerOptions unitConfig ]); }; socketUnit = optionalSystemdUnitOption "socket" "sockets" // { - type = - let - inherit (utils.systemdUtils.unitOptions) socketOptions commonUnitOptions; - inherit (utils.systemdUtils.lib) unitConfig; - in - with lib.types; nullOr (submodule [ - commonUnitOptions - socketOptions - unitConfig - ]); + type = let + inherit (utils.systemdUtils.unitOptions) + socketOptions commonUnitOptions; + inherit (utils.systemdUtils.lib) unitConfig; + in with lib.types; + nullOr (submodule [ commonUnitOptions socketOptions unitConfig ]); }; pathUnit = optionalSystemdUnitOption "path" "paths" // { - type = - let - inherit (utils.systemdUtils.unitOptions) pathOptions commonUnitOptions; - inherit (utils.systemdUtils.lib) unitConfig; - in - with lib.types; nullOr (submodule [ - commonUnitOptions - pathOptions - unitConfig - ]); + type = let + inherit (utils.systemdUtils.unitOptions) pathOptions commonUnitOptions; + inherit (utils.systemdUtils.lib) unitConfig; + in with lib.types; + nullOr (submodule [ commonUnitOptions pathOptions unitConfig ]); }; id = lib.mkOption { @@ -141,26 +120,25 @@ in }; config = { - /* - Setting some recommendation and requirements for sessiond components. - Note there are the missing directives that COULD include some sane - defaults here. + /* Setting some recommendation and requirements for sessiond components. + Note there are the missing directives that COULD include some sane + defaults here. - * The `Unit.OnFailure=` and `Unit.OnFailureJobMode=` directives. Since - different components don't have the same priority and don't handle - failures the same way, we didn't set it here. This is on the user to - know how different desktop components interact with each other - especially if one of them failed. + * The `Unit.OnFailure=` and `Unit.OnFailureJobMode=` directives. Since + different components don't have the same priority and don't handle + failures the same way, we didn't set it here. This is on the user to + know how different desktop components interact with each other + especially if one of them failed. - * Even if we have a way to limit starting desktop components with - `systemd-xdg-autostart-condition`, using `Service.ExecCondition=` would - severely limit possible reuse of desktop components with other - NixOS-module-generated gnome-session sessions so we're not bothering with - those. + * Even if we have a way to limit starting desktop components with + `systemd-xdg-autostart-condition`, using `Service.ExecCondition=` would + severely limit possible reuse of desktop components with other + NixOS-module-generated gnome-session sessions so we're not bothering with + those. - * Most sandboxing options. Aside from the fact we're dealing with a - systemd user unit, much of them are unnecessary and rarely needed (if - ever like `Service.PrivateTmp=`?) so we didn't set such defaults here. + * Most sandboxing options. Aside from the fact we're dealing with a + systemd user unit, much of them are unnecessary and rarely needed (if + ever like `Service.PrivateTmp=`?) so we didn't set such defaults here. */ serviceUnit = { description = lib.mkDefault config.description; @@ -194,14 +172,13 @@ in }; }; - /* - Take note the session target unit already has `Wants=$COMPONENT.target` - so no need to set dependency ordering directives here. + /* Take note the session target unit already has `Wants=$COMPONENT.target` + so no need to set dependency ordering directives here. - And another thing, we also didn't set any dependency ordering directives - to any of sessiond-specific systemd units (if there's any). It is more - likely that the user will design their own desktop session with full - control so this would be better set as empty for less confusion. + And another thing, we also didn't set any dependency ordering directives + to any of sessiond-specific systemd units (if there's any). It is more + likely that the user will design their own desktop session with full + control so this would be better set as empty for less confusion. */ targetUnit = { wants = [ "${config.id}.service" ]; diff --git a/modules/nixos/programs/sessiond/submodules/session-type.nix b/modules/nixos/programs/sessiond/submodules/session-type.nix index beb1c000..d77f765a 100644 --- a/modules/nixos/programs/sessiond/submodules/session-type.nix +++ b/modules/nixos/programs/sessiond/submodules/session-type.nix @@ -29,9 +29,9 @@ let # This is used both as the configuration format for sessiond.conf and its # hooks. settingsFormat = pkgs.formats.toml { }; - sessionSettingsFile = settingsFormat.generate "sessiond-conf-${config.name}" config.settings; -in -{ + sessionSettingsFile = + settingsFormat.generate "sessiond-conf-${config.name}" config.settings; +in { options = { name = lib.mkOption { type = lib.types.nonEmptyStr; @@ -70,13 +70,11 @@ in default = [ config.fullName ]; defaultText = "[ .fullName ]"; apply = names: - builtins.map - (name: - if (lib.elem name validDesktopNames) || (lib.hasPrefix "X-" name) then - name - else - "X-${name}") - names; + builtins.map (name: + if (lib.elem name validDesktopNames) || (lib.hasPrefix "X-" name) then + name + else + "X-${name}") names; example = [ "GNOME" "Garden" ]; }; @@ -109,21 +107,23 @@ in A one-sentence description of the desktop environment. ''; default = "${config.fullName} desktop environment"; - defaultText = lib.literalExpression "\${.fullName} desktop environment"; + defaultText = + lib.literalExpression "\${.fullName} desktop environment"; example = "A desktop environment featuring a scrolling compositor."; }; components = lib.mkOption { - type = with lib.types; attrsOf (submoduleWith { - specialArgs = { - inherit utils; - session = { - inherit (config) fullName desktopNames description; - inherit name; + type = with lib.types; + attrsOf (submoduleWith { + specialArgs = { + inherit utils; + session = { + inherit (config) fullName desktopNames description; + inherit name; + }; }; - }; - modules = [ ./component-type.nix ]; - }); + modules = [ ./component-type.nix ]; + }); description = '' The individual components to be launched with the desktop session. ''; @@ -135,15 +135,10 @@ in }; targetUnit = lib.mkOption { - type = - let - inherit (utils.systemdUtils.lib) unitConfig; - inherit (utils.systemdUtils.unitOptions) commonUnitOptions; - in - lib.types.submodule [ - commonUnitOptions - unitConfig - ]; + type = let + inherit (utils.systemdUtils.lib) unitConfig; + inherit (utils.systemdUtils.unitOptions) commonUnitOptions; + in lib.types.submodule [ commonUnitOptions unitConfig ]; description = '' systemd target configuration to be generated for `.target`. @@ -169,17 +164,16 @@ in }; serviceUnit = lib.mkOption { - type = - let - inherit (utils.systemdUtils.lib) unitConfig serviceConfig; - inherit (utils.systemdUtils.unitOptions) commonUnitOptions serviceOptions; - in - lib.types.submodule [ - commonUnitOptions - serviceOptions - serviceConfig - unitConfig - ]; + type = let + inherit (utils.systemdUtils.lib) unitConfig serviceConfig; + inherit (utils.systemdUtils.unitOptions) + commonUnitOptions serviceOptions; + in lib.types.submodule [ + commonUnitOptions + serviceOptions + serviceConfig + unitConfig + ]; default = { }; visible = "shallow"; description = '' @@ -218,17 +212,17 @@ in # Append the session argument. config = { - extraArgs = lib.optional (config.settings != { }) "--config=${sessionSettingsFile}"; + extraArgs = + lib.optional (config.settings != { }) "--config=${sessionSettingsFile}"; targetUnit = { description = config.description; requires = [ "${config.name}.service" ]; - wants = - let - componentTargetUnits = - lib.mapAttrsToList (_: component: "${component.id}.target") config.components; - in - componentTargetUnits; + wants = let + componentTargetUnits = + lib.mapAttrsToList (_: component: "${component.id}.target") + config.components; + in componentTargetUnits; }; serviceUnit = { @@ -243,7 +237,9 @@ in Slice = lib.mkForce "session.slice"; Type = lib.mkForce "dbus"; BusName = lib.mkForce "org.sessiond.session1"; - ExecStart = lib.mkForce "${lib.getExe' sessiondPkg "sessiond"} ${lib.concatStringsSep " " config.extraArgs}"; + ExecStart = lib.mkForce "${lib.getExe' sessiondPkg "sessiond"} ${ + lib.concatStringsSep " " config.extraArgs + }"; Restart = "always"; }; diff --git a/modules/nixos/programs/wezterm.nix b/modules/nixos/programs/wezterm.nix index 70075c0b..5246688d 100644 --- a/modules/nixos/programs/wezterm.nix +++ b/modules/nixos/programs/wezterm.nix @@ -7,8 +7,7 @@ let source ${pkgs.bash-preexec}/share/bash/bash-preexec.sh source ${cfg.package}/etc/profile.d/wezterm.sh ''; -in -{ +in { options.programs.wezterm = { enable = lib.mkEnableOption "Wezterm terminal emulator"; package = lib.mkOption { diff --git a/modules/nixos/services/archivebox.nix b/modules/nixos/services/archivebox.nix index 3ba81461..4be75cb4 100644 --- a/modules/nixos/services/archivebox.nix +++ b/modules/nixos/services/archivebox.nix @@ -42,55 +42,48 @@ let }; mkJobService = name: value: - lib.nameValuePair - (jobUnitName name) - { - description = "Archivebox download group '${name}'"; - after = [ "network-online.target" ]; - wants = [ "network-online.target" ]; - documentation = [ "https://docs.archivebox.io/" ]; - path = [ cfg.package ] ++ cfg.extraPackages; - script = '' - echo "${lib.concatStringsSep "\n" value.urls}" \ - | archivebox add ${lib.escapeShellArgs value.extraArgs} - ''; - serviceConfig = { - User = "archivebox"; - Group = "archivebox"; + lib.nameValuePair (jobUnitName name) { + description = "Archivebox download group '${name}'"; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + documentation = [ "https://docs.archivebox.io/" ]; + path = [ cfg.package ] ++ cfg.extraPackages; + script = '' + echo "${lib.concatStringsSep "\n" value.urls}" \ + | archivebox add ${lib.escapeShellArgs value.extraArgs} + ''; + serviceConfig = { + User = "archivebox"; + Group = "archivebox"; - LockPersonality = true; - NoNewPrivileges = true; + LockPersonality = true; + NoNewPrivileges = true; - PrivateTmp = true; - PrivateDevices = true; + PrivateTmp = true; + PrivateDevices = true; - ProtectControlGroups = true; - ProtectClock = true; - ProtectKernelLogs = true; - ProtectKernelModules = true; - ProtectKernelTunables = true; - ProtectProc = "invisible"; - ProtectHome = true; - ProtectSystem = "strict"; + ProtectControlGroups = true; + ProtectClock = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + ProtectProc = "invisible"; + ProtectHome = true; + ProtectSystem = "strict"; - RestrictAddressFamilies = [ - "AF_LOCAL" - "AF_INET" - "AF_INET6" - ]; - RestrictNamespaces = true; + RestrictAddressFamilies = [ "AF_LOCAL" "AF_INET" "AF_INET6" ]; + RestrictNamespaces = true; - SystemCallFilter = [ "@system-service" ]; - SystemCallErrorNumber = "EPERM"; + SystemCallFilter = [ "@system-service" ]; + SystemCallErrorNumber = "EPERM"; - StateDirectory = "archivebox"; - }; + StateDirectory = "archivebox"; }; + }; mkTimerUnit = name: value: lib.nameValuePair (jobUnitName name) { - description = - "Archivebox download job '${name}'"; + description = "Archivebox download job '${name}'"; documentation = [ "https://docs.archivebox.io/" ]; timerConfig = { Persistent = true; @@ -99,8 +92,7 @@ let }; wantedBy = [ "timers.target" ]; }; -in -{ +in { options.services.archivebox = { enable = lib.mkEnableOption "Archivebox service"; @@ -121,10 +113,7 @@ in }; research = { - urls = [ - "https://arxiv.org/rss/cs" - "https://distill.pub/" - ]; + urls = [ "https://arxiv.org/rss/cs" "https://distill.pub/" ]; extraArgs = [ "--depth" "1" ]; startAt = "daily"; }; @@ -138,14 +127,9 @@ in default, it sets the optional dependencies of ArchiveBox for additional download formats and capabilities. ''; - default = with pkgs; [ - chromium - nodejs_latest - wget - curl - yt-dlp - readability-cli - ] ++ lib.optional config.programs.git.enable config.programs.git.package; + default = with pkgs; + [ chromium nodejs_latest wget curl yt-dlp readability-cli ] + ++ lib.optional config.programs.git.enable config.programs.git.package; defaultText = '' Chromium, NodeJS, wget, yt-dlp, and git if enabled. ''; @@ -194,9 +178,10 @@ in User = "archivebox"; Group = "archivebox"; - ExecStart = "${lib.getExe' cfg.package "archivebox"} server localhost:${ - toString cfg.webserver.port - }"; + ExecStart = + "${lib.getExe' cfg.package "archivebox"} server localhost:${ + toString cfg.webserver.port + }"; CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ]; @@ -213,11 +198,7 @@ in ProtectKernelModules = true; ProtectKernelTunables = true; - RestrictAddressFamilies = [ - "AF_LOCAL" - "AF_INET" - "AF_INET6" - ]; + RestrictAddressFamilies = [ "AF_LOCAL" "AF_INET" "AF_INET6" ]; RestrictNamespaces = true; SystemCallFilter = [ "@system-service" ]; diff --git a/modules/nixos/services/crowdsec.nix b/modules/nixos/services/crowdsec.nix index af0d2d50..4384fa57 100644 --- a/modules/nixos/services/crowdsec.nix +++ b/modules/nixos/services/crowdsec.nix @@ -11,23 +11,19 @@ let # Set all of the related Crowdsec configuration options from the user-given # service module config. config = lib.mkMerge [ - ( - let - plugins = lib.filterAttrs (n: v: v.package != null) cfg.notificationPlugins; - in - lib.mkIf (plugins != { }) { - config_paths.plugin_dir = lib.mkDefault pluginsDir; - } - ) + (let + plugins = + lib.filterAttrs (n: v: v.package != null) cfg.notificationPlugins; + in lib.mkIf (plugins != { }) { + config_paths.plugin_dir = lib.mkDefault pluginsDir; + }) - ( - let - pluginsSettings = lib.filterAttrs (n: v: v.settings != { }) cfg.notificationPlugins; - in - lib.mkIf (pluginsSettings != { }) { - config_paths.notification_dir = lib.mkDefault pluginsConfigDrv; - } - ) + (let + pluginsSettings = + lib.filterAttrs (n: v: v.settings != { }) cfg.notificationPlugins; + in lib.mkIf (pluginsSettings != { }) { + config_paths.notification_dir = lib.mkDefault pluginsConfigDrv; + }) (lib.mkIf (cfg.dataSources != { }) { crowdsec_service.acqusition_dir = lib.mkDefault acqusitionsDir; @@ -37,28 +33,25 @@ let pluginsDir = pkgs.symlinkJoin { name = "crowdsec-system-notification-plugins"; - paths = - let - plugins = lib.filterAttrs (n: v: v.package != null) cfg.notificationPlugins; - in - lib.mapAttrsToList (n: v: "${v.package}/share/crowdsec") plugins; + paths = let + plugins = + lib.filterAttrs (n: v: v.package != null) cfg.notificationPlugins; + in lib.mapAttrsToList (n: v: "${v.package}/share/crowdsec") plugins; }; pluginsConfigDrv = let - pluginsConfigs = - lib.mapAttrsToList - (n: v: settingsFormat.generate "crowdsec-system-plugin-config-${n}" v.settings) - cfg.notificationPlugins; + pluginsConfigs = lib.mapAttrsToList (n: v: + settingsFormat.generate "crowdsec-system-plugin-config-${n}" v.settings) + cfg.notificationPlugins; in pkgs.symlinkJoin { name = "crowdsec-system-notification-plugins-configs"; paths = pluginsConfigs; }; acqusitionsDir = let - acqusitionConfigs = - lib.mapAttrsToList - (n: v: settingsFormat.generate "crowdsec-system-acqusition-config-${n}" v.settings) - cfg.dataSources; + acqusitionConfigs = lib.mapAttrsToList (n: v: + settingsFormat.generate "crowdsec-system-acqusition-config-${n}" + v.settings) cfg.dataSources; in pkgs.symlinkJoin { name = "crowdsec-system-acqusitions-configs"; paths = acqusitionConfigs; @@ -104,18 +97,16 @@ let default = { }; example = { source = "journalctl"; - journalctl_filter = [ - "_SYSTEMD_UNIT=ssh.service" - ]; + journalctl_filter = [ "_SYSTEMD_UNIT=ssh.service" ]; }; }; }; configFile = settingsFormat.generate "crowdsec-config" cfg.settings; -in -{ +in { options.services.crowdsec = { - enable = lib.mkEnableOption "[Crowdsec](https://crowdsec.net), a monitoring service using crowdsourced data"; + enable = lib.mkEnableOption + "[Crowdsec](https://crowdsec.net), a monitoring service using crowdsourced data"; package = lib.mkPackageOption pkgs "crowdsec" { }; @@ -188,9 +179,7 @@ in example = { ssh = { source = "journalctl"; - journalctl_filter = [ - "_SYSTEMD_UNIT=ssh.service" - ]; + journalctl_filter = [ "_SYSTEMD_UNIT=ssh.service" ]; labels.type = "syslog"; }; }; @@ -201,7 +190,9 @@ in systemd.services.crowdsec = { description = "Crowdsec monitoring server"; script = '' - ${lib.getExe' cfg.package "crowdsec"} -c ${configFile} ${lib.escapeShellArgs cfg.extraArgs} + ${lib.getExe' cfg.package "crowdsec"} -c ${configFile} ${ + lib.escapeShellArgs cfg.extraArgs + } ''; after = [ "syslog.target" @@ -215,9 +206,8 @@ in serviceConfig = { ExecReload = "kill -HUP $MAINPID"; ReadWritePaths = - lib.optionals (cfg.settings.common.log_media or "" == "file") [ - cfg.settings.common.log_folder - ]; + lib.optionals (cfg.settings.common.log_media or "" == "file") + [ cfg.settings.common.log_folder ]; User = "crowdsec"; Group = "crowdsec"; @@ -249,11 +239,7 @@ in SystemCallFilter = [ "@system-service" ]; SystemCallErrorNumber = "EPERM"; - RestrictAddressFamilies = [ - "AF_LOCAL" - "AF_INET" - "AF_INET6" - ]; + RestrictAddressFamilies = [ "AF_LOCAL" "AF_INET" "AF_INET6" ]; RestrictNamespaces = true; RestrictSUIDGUID = true; MemoryDenyWriteExecute = true; diff --git a/modules/nixos/services/ctrld.nix b/modules/nixos/services/ctrld.nix index 5df489ab..ef88a161 100644 --- a/modules/nixos/services/ctrld.nix +++ b/modules/nixos/services/ctrld.nix @@ -5,8 +5,7 @@ let settingsFormat = pkgs.formats.toml { }; settingsFile = settingsFile.generate "ctrld-proxy-settings" cfg.settings; -in -{ +in { options.services.ctrld = { enable = lib.mkEnableOption "ctrld, a DNS forwarding proxy"; package = lib.mkPackageOption pkgs "ctrld" { }; @@ -81,11 +80,7 @@ in ProtectKernelModules = true; ProtectKernelTunables = true; ProtectSystem = "full"; - RestrictAddressFamilies = [ - "AF_LOCAL" - "AF_INET" - "AF_INET6" - ]; + RestrictAddressFamilies = [ "AF_LOCAL" "AF_INET" "AF_INET6" ]; RestrictNamespaces = true; SystemCallArchitectures = [ "native" ]; SystemCallFilter = [ "@system-service" ]; diff --git a/modules/nixos/services/docker-compose.nix b/modules/nixos/services/docker-compose.nix index c45f6389..33928431 100644 --- a/modules/nixos/services/docker-compose.nix +++ b/modules/nixos/services/docker-compose.nix @@ -20,7 +20,7 @@ let description = '' List of files to be used when setting up the docker-compose service. ''; - default = []; + default = [ ]; example = lib.literalExpression '' [ /path/to/docker-compose.yml @@ -34,18 +34,17 @@ let Configuration to be used for the docker-compose process. ''; default = { }; - example = { - }; + example = { }; }; }; config = { - extraArgs = - cfg.extraArgs + extraArgs = cfg.extraArgs ++ lib.concatMap (f: [ "--file" f ]) config.files; files = lib.optionals (config.settings != { }) [ - (settingsFormat.generate "docker-compose-generated-${name}" config.settings) + (settingsFormat.generate "docker-compose-generated-${name}" + config.settings) ]; }; }; @@ -61,14 +60,13 @@ let RemainAfterExit = true; }; }; -in -{ +in { options.services.docker-compose = { enable = lib.mkEnableOption "integration with docker-compose"; extraArgs = lib.mkOption { type = with lib.types; listOf str; - default = []; + default = [ ]; }; jobs = lib.mkOption { diff --git a/modules/nixos/services/gallery-dl.nix b/modules/nixos/services/gallery-dl.nix index a2128713..4aa22f7f 100644 --- a/modules/nixos/services/gallery-dl.nix +++ b/modules/nixos/services/gallery-dl.nix @@ -70,15 +70,13 @@ let settings = cfg.settings; }; }; -in -{ +in { options.services.gallery-dl = { enable = lib.mkEnableOption "archiving services with gallery-dl"; package = lib.mkOption { type = lib.types.package; - description = - "Package containing the {command}`gallery-dl` binary."; + description = "Package containing the {command}`gallery-dl` binary."; default = pkgs.gallery-dl; defaultText = lib.literalExpression "pkgs.gallery-dl"; }; @@ -150,67 +148,61 @@ in }; config = lib.mkIf cfg.enable { - systemd.services = lib.mapAttrs' - (name: value: - lib.nameValuePair (jobUnitName name) { - wantedBy = [ "multi-user.target" ]; - description = "gallery-dl archive job for group '${name}'"; - documentation = [ "man:gallery-dl(1)" ]; - enable = true; - path = with pkgs; [ brotli ffmpeg cfg.package ]; - preStart = '' - mkdir -p ${lib.escapeShellArg value.downloadPath} - ''; + systemd.services = lib.mapAttrs' (name: value: + lib.nameValuePair (jobUnitName name) { + wantedBy = [ "multi-user.target" ]; + description = "gallery-dl archive job for group '${name}'"; + documentation = [ "man:gallery-dl(1)" ]; + enable = true; + path = with pkgs; [ brotli ffmpeg cfg.package ]; + preStart = '' + mkdir -p ${lib.escapeShellArg value.downloadPath} + ''; - # Order matters here. We're letting service-level arguments and - # settings to be overridden with job-specific things as much as - # possible especially with the settings. - # - # Regarding to settings (`settings`) and extra arguments - # (`extraArgs`), the settings is the last applied argument with - # `--config` option. This means that it will cascade resultings - # settings from `extraArgs` if there's any related option that is - # given like another `--config` for example. - script = - let - jobLevelSettingsFile = - settingsFormat.generate "gallery-dl-job-${name}-settings" - value.settings; - in - '' - gallery-dl ${lib.escapeShellArgs value.extraArgs} ${ - lib.optionalString (value.settings != null) - "--config ${jobLevelSettingsFile}" - } --destination ${lib.escapeShellArg value.downloadPath} ${ - lib.escapeShellArgs value.urls - } - ''; - startAt = value.startAt; - serviceConfig = { - LockPersonality = true; - NoNewPrivileges = true; - PrivateTmp = true; - PrivateUsers = true; - PrivateDevices = true; - ProtectControlGroups = true; - ProtectClock = true; - ProtectKernelLogs = true; - ProtectKernelModules = true; - ProtectKernelTunables = true; - SystemCallFilter = "@system-service"; - SystemCallErrorNumber = "EPERM"; - }; - }) - cfg.jobs; + # Order matters here. We're letting service-level arguments and + # settings to be overridden with job-specific things as much as + # possible especially with the settings. + # + # Regarding to settings (`settings`) and extra arguments + # (`extraArgs`), the settings is the last applied argument with + # `--config` option. This means that it will cascade resultings + # settings from `extraArgs` if there's any related option that is + # given like another `--config` for example. + script = let + jobLevelSettingsFile = + settingsFormat.generate "gallery-dl-job-${name}-settings" + value.settings; + in '' + gallery-dl ${lib.escapeShellArgs value.extraArgs} ${ + lib.optionalString (value.settings != null) + "--config ${jobLevelSettingsFile}" + } --destination ${lib.escapeShellArg value.downloadPath} ${ + lib.escapeShellArgs value.urls + } + ''; + startAt = value.startAt; + serviceConfig = { + LockPersonality = true; + NoNewPrivileges = true; + PrivateTmp = true; + PrivateUsers = true; + PrivateDevices = true; + ProtectControlGroups = true; + ProtectClock = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + SystemCallFilter = "@system-service"; + SystemCallErrorNumber = "EPERM"; + }; + }) cfg.jobs; - systemd.timers = lib.mapAttrs' - (name: value: - lib.nameValuePair (jobUnitName name) { - timerConfig = { - Persistent = true; - RandomizedDelaySec = "2min"; - }; - }) - cfg.jobs; + systemd.timers = lib.mapAttrs' (name: value: + lib.nameValuePair (jobUnitName name) { + timerConfig = { + Persistent = true; + RandomizedDelaySec = "2min"; + }; + }) cfg.jobs; }; } diff --git a/modules/nixos/services/uxplay.nix b/modules/nixos/services/uxplay.nix index ad7ca43d..c9d3d658 100644 --- a/modules/nixos/services/uxplay.nix +++ b/modules/nixos/services/uxplay.nix @@ -1,9 +1,7 @@ { config, lib, pkgs, ... }: -let - cfg = config.services.uxplay; -in -{ +let cfg = config.services.uxplay; +in { options.services.uxplay = { enable = lib.mkEnableOption "uxplay, an Airplay mirroring server"; @@ -34,7 +32,9 @@ in after = [ "network.target" ]; documentation = [ "man:uxplay(1)" ]; wantedBy = [ "multi-user.target" ]; - script = "${lib.getExe' cfg.package "uxplay"} ${lib.escapeShellArgs cfg.extraArgs}"; + script = "${lib.getExe' cfg.package "uxplay"} ${ + lib.escapeShellArgs cfg.extraArgs + }"; serviceConfig = { DynamicUser = true; User = "uxplay"; @@ -59,11 +59,7 @@ in ProtectKernelTunables = true; RestrictRealtime = true; - RestrictAddressFamilies = [ - "AF_LOCAL" - "AF_INET" - "AF_INET6" - ]; + RestrictAddressFamilies = [ "AF_LOCAL" "AF_INET" "AF_INET6" ]; RestrictNamespaces = true; SystemCallFilter = [ "@system-service" "~@privileged" ]; diff --git a/modules/nixos/services/vouch-proxy.nix b/modules/nixos/services/vouch-proxy.nix index df1d32ca..b8598b87 100644 --- a/modules/nixos/services/vouch-proxy.nix +++ b/modules/nixos/services/vouch-proxy.nix @@ -62,20 +62,17 @@ let let inherit (instance) settings settingsFile; settingsFile' = "/var/lib/vouch-proxy/${name}-config.yml"; - in - lib.nameValuePair "vouch-proxy-${utils.escapeSystemdPath name}" { - preStart = - if (settings != { } && settingsFile == null) - then '' - ${pkgs.writeScript - "vouch-proxy-replace-secrets" - (utils.genJqSecretsReplacementSnippet settings settingsFile')} - chmod 0600 "${settingsFile'}" - '' - else '' - install -Dm0600 "${settingsFile}" "${settingsFile'}" - ''; - script = "${lib.getExe' instance.package "vouch-proxy"} -config ${settingsFile'}"; + in lib.nameValuePair "vouch-proxy-${utils.escapeSystemdPath name}" { + preStart = if (settings != { } && settingsFile == null) then '' + ${pkgs.writeScript "vouch-proxy-replace-secrets" + (utils.genJqSecretsReplacementSnippet settings settingsFile')} + chmod 0600 "${settingsFile'}" + '' else '' + install -Dm0600 "${settingsFile}" "${settingsFile'}" + ''; + script = "${ + lib.getExe' instance.package "vouch-proxy" + } -config ${settingsFile'}"; serviceConfig = { User = config.users.users.vouch-proxy.name; Group = config.users.groups.vouch-proxy.name; @@ -119,19 +116,15 @@ let AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ]; # Limit this service to Unix sockets and IPs. - RestrictAddressFamilies = [ - "AF_LOCAL" - "AF_INET" - "AF_INET6" - ]; + RestrictAddressFamilies = [ "AF_LOCAL" "AF_INET" "AF_INET6" ]; RestrictNamespaces = true; }; wantedBy = [ "multi-user.target" ]; }; -in -{ +in { options.services.vouch-proxy = { - enable = lib.mkEnableOption "Vouch Proxy, a proxy for SSO and OAuth/OIDC logins"; + enable = + lib.mkEnableOption "Vouch Proxy, a proxy for SSO and OAuth/OIDC logins"; instances = lib.mkOption { type = with lib.types; attrsOf (submodule instanceType); @@ -155,7 +148,7 @@ in code_challenge_method = "S256"; auth_url = "https://auth.example.com/ui/oauth2"; token_url = "https://auth.example.com/oauth2/token"; - user_info_url = "https://auth.example.com/oauth2/openid/$${client_id}/userinfo"; + user_info_url = "https://auth.example.com/oauth2/openid/$''${client_id}/userinfo"; scopes = [ "login" "email" ]; callback_url = "https://auth.example.com/auth"; }; diff --git a/modules/nixos/services/wezterm-mux-server.nix b/modules/nixos/services/wezterm-mux-server.nix index bf93696f..662a4af6 100644 --- a/modules/nixos/services/wezterm-mux-server.nix +++ b/modules/nixos/services/wezterm-mux-server.nix @@ -1,9 +1,7 @@ { config, lib, pkgs, ... }: -let - cfg = config.services.wezterm-mux-server; -in -{ +let cfg = config.services.wezterm-mux-server; +in { options.services.wezterm-mux-server = { enable = lib.mkEnableOption "Wezterm mux server"; @@ -37,7 +35,10 @@ in wantedBy = [ "multi-user.target" ]; script = '' - wezterm-mux-server ${lib.optionalString (cfg.configFile != null) "--config-file ${cfg.configFile}"} + wezterm-mux-server ${ + lib.optionalString (cfg.configFile != null) + "--config-file ${cfg.configFile}" + } ''; # Give it some tough love. diff --git a/modules/nixos/services/yt-dlp.nix b/modules/nixos/services/yt-dlp.nix index 63aee604..20b3252e 100644 --- a/modules/nixos/services/yt-dlp.nix +++ b/modules/nixos/services/yt-dlp.nix @@ -72,25 +72,21 @@ let }; }; - config.extraArgs = - let - mkPathArg = n: v: - lib.optionals (v.output != null) [ "--output" "${n}:${v.output}" ] - ++ lib.optionals (v.path != null) [ "--paths" "${n}:${v.path}" ]; - in - cfg.extraArgs - ++ (lib.lists.flatten (lib.mapAttrsToList mkPathArg config.metadata)) - ++ [ "--paths" config.downloadPath ]; + config.extraArgs = let + mkPathArg = n: v: + lib.optionals (v.output != null) [ "--output" "${n}:${v.output}" ] + ++ lib.optionals (v.path != null) [ "--paths" "${n}:${v.path}" ]; + in cfg.extraArgs + ++ (lib.lists.flatten (lib.mapAttrsToList mkPathArg config.metadata)) + ++ [ "--paths" config.downloadPath ]; }; -in -{ +in { options.services.yt-dlp = { enable = lib.mkEnableOption "archiving service with yt-dlp"; package = lib.mkOption { type = lib.types.package; - description = - "The derivation that contains {command}`yt-dlp` binary."; + description = "The derivation that contains {command}`yt-dlp` binary."; default = pkgs.yt-dlp; defaultText = lib.literalExpression "pkgs.yt-dlp"; example = lib.literalExpression @@ -99,7 +95,8 @@ in downloadPath = lib.mkOption { type = lib.types.path; - description = "Download path of the service to be given per job (unless overridden)."; + description = + "Download path of the service to be given per job (unless overridden)."; default = "/var/yt-dlp"; example = "/srv/Videos"; }; @@ -121,8 +118,7 @@ in extraArgs = lib.mkOption { type = with lib.types; listOf str; - description = - "Global list of arguments to be passed to each yt-dlp job."; + description = "Global list of arguments to be passed to each yt-dlp job."; default = [ ]; example = lib.literalExpression '' [ @@ -163,67 +159,59 @@ in }; config = lib.mkIf cfg.enable { - systemd.services = lib.mapAttrs' - (name: job: - lib.nameValuePair (jobUnitName name) { - inherit (job) startAt; - wantedBy = [ "multi-user.target" ]; - wants = [ "network-online.target" ]; - after = [ "network-online.target" ]; - description = "yt-dlp archive job for group '${name}'"; - documentation = [ "man:yt-dlp(1)" ]; - enable = true; - script = '' - ${lib.getExe' cfg.package "yt-dlp"} \ - ${lib.escapeShellArgs job.extraArgs} \ - ${lib.escapeShellArgs job.urls} - ''; - serviceConfig = { - ReadWritePaths = - [ job.downloadPath ] - ++ lib.lists.flatten (lib.mapAttrsToList (n: v: lib.optionals (v.path != null) v.path) job.metadata); + systemd.services = lib.mapAttrs' (name: job: + lib.nameValuePair (jobUnitName name) { + inherit (job) startAt; + wantedBy = [ "multi-user.target" ]; + wants = [ "network-online.target" ]; + after = [ "network-online.target" ]; + description = "yt-dlp archive job for group '${name}'"; + documentation = [ "man:yt-dlp(1)" ]; + enable = true; + script = '' + ${lib.getExe' cfg.package "yt-dlp"} \ + ${lib.escapeShellArgs job.extraArgs} \ + ${lib.escapeShellArgs job.urls} + ''; + serviceConfig = { + ReadWritePaths = [ job.downloadPath ] ++ lib.lists.flatten + (lib.mapAttrsToList (n: v: lib.optionals (v.path != null) v.path) + job.metadata); - LockPersonality = true; - NoNewPrivileges = true; - PrivateDevices = true; - PrivateTmp = true; - PrivateUsers = true; - PrivateMounts = true; - ProtectClock = true; - ProtectControlGroups = true; - ProtectHome = true; - ProtectKernelLogs = true; - ProtectKernelModules = true; - ProtectKernelTunables = true; - ProtectSystem = "full"; - RemoveIPC = true; - StandardOutput = "journal"; - StandardError = "journal"; - SystemCallFilter = "@system-service"; - SystemCallErrorNumber = "EPERM"; + LockPersonality = true; + NoNewPrivileges = true; + PrivateDevices = true; + PrivateTmp = true; + PrivateUsers = true; + PrivateMounts = true; + ProtectClock = true; + ProtectControlGroups = true; + ProtectHome = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + ProtectSystem = "full"; + RemoveIPC = true; + StandardOutput = "journal"; + StandardError = "journal"; + SystemCallFilter = "@system-service"; + SystemCallErrorNumber = "EPERM"; - CapabilityBoundingSet = lib.mkDefault [ ]; - AmbientCapabilities = lib.mkDefault [ ]; - RestrictAddressFamilies = [ - "AF_LOCAL" - "AF_INET" - "AF_INET6" - ]; - RestrictNamespaces = true; - RestrictSUIDGUID = true; - MemoryDenyWriteExecute = true; - }; - }) - cfg.jobs; + CapabilityBoundingSet = lib.mkDefault [ ]; + AmbientCapabilities = lib.mkDefault [ ]; + RestrictAddressFamilies = [ "AF_LOCAL" "AF_INET" "AF_INET6" ]; + RestrictNamespaces = true; + RestrictSUIDGUID = true; + MemoryDenyWriteExecute = true; + }; + }) cfg.jobs; - systemd.timers = lib.mapAttrs' - (name: value: - lib.nameValuePair (jobUnitName name) { - timerConfig = { - Persistent = true; - RandomizedDelaySec = "2min"; - }; - }) - cfg.jobs; + systemd.timers = lib.mapAttrs' (name: value: + lib.nameValuePair (jobUnitName name) { + timerConfig = { + Persistent = true; + RandomizedDelaySec = "2min"; + }; + }) cfg.jobs; }; } diff --git a/modules/nixos/virtualisation/oci-containers/default.nix b/modules/nixos/virtualisation/oci-containers/default.nix index f088cce5..007fd853 100644 --- a/modules/nixos/virtualisation/oci-containers/default.nix +++ b/modules/nixos/virtualisation/oci-containers/default.nix @@ -1,6 +1 @@ -{ - imports = [ - ./networks.nix - ./volumes.nix - ]; -} +{ imports = [ ./networks.nix ./volumes.nix ]; } diff --git a/modules/nixos/virtualisation/oci-containers/networks.nix b/modules/nixos/virtualisation/oci-containers/networks.nix index ffe3f768..4f1861ff 100644 --- a/modules/nixos/virtualisation/oci-containers/networks.nix +++ b/modules/nixos/virtualisation/oci-containers/networks.nix @@ -12,9 +12,7 @@ let description = '' A list of labels to be attached to the network at runtime. ''; - example = { - "foo" = "baz"; - }; + example = { "foo" = "baz"; }; }; ipv6 = lib.mkOption { @@ -41,45 +39,44 @@ let }; }; - config.extraOptions = - lib.optionals config.ipv6 [ "--ipv6" ] - ++ lib.mapAttrsToList (name: value: "--label ${name}=${value}") config.labels; + config.extraOptions = lib.optionals config.ipv6 [ "--ipv6" ] + ++ lib.mapAttrsToList (name: value: "--label ${name}=${value}") + config.labels; }; - mkService = name: value: let - removeScript = - if cfg.backend == "podman" - then "podman network rm --force ${name}" - else "${cfg.backend} network rm -f ${name}"; + mkService = name: value: + let + removeScript = if cfg.backend == "podman" then + "podman network rm --force ${name}" + else + "${cfg.backend} network rm -f ${name}"; - preStartScript = pkgs.writeShellScript "pre-start-oci-container-network-${name}" '' - ${removeScript} - ''; - in { - path = - if cfg.backend == "docker" then [ config.virtualisation.docker.package ] - else if cfg.backend == "podman" then [ config.virtualisation.podman.package ] - else throw "Unhandled backend: ${cfg.backend}"; - script = lib.concatStringsSep " \\\n " ([ - "exec ${cfg.backend} " - ] ++ (map escapeShellArg value.preRunExtraOptions) ++ [ - "network create" - ] ++ (map escapeShellArg value.extraOptions) ++ [ - name - ]); - postStop = removeScript; + preStartScript = + pkgs.writeShellScript "pre-start-oci-container-network-${name}" '' + ${removeScript} + ''; + in { + path = if cfg.backend == "docker" then + [ config.virtualisation.docker.package ] + else if cfg.backend == "podman" then + [ config.virtualisation.podman.package ] + else + throw "Unhandled backend: ${cfg.backend}"; + script = lib.concatStringsSep " \\\n " ([ "exec ${cfg.backend} " ] + ++ (map escapeShellArg value.preRunExtraOptions) ++ [ "network create" ] + ++ (map escapeShellArg value.extraOptions) ++ [ name ]); + postStop = removeScript; - serviceConfig = { - ExecStartPre = [ preStartScript ]; - Type = "oneshot"; - RemainAfterExit = true; + serviceConfig = { + ExecStartPre = [ preStartScript ]; + Type = "oneshot"; + RemainAfterExit = true; + }; + + before = [ "multi-user.target" ]; + wantedBy = [ "multi-user.target" ]; }; - - before = [ "multi-user.target" ]; - wantedBy = [ "multi-user.target" ]; - }; -in -{ +in { options.virtualisation.oci-containers.networks = lib.mkOption { type = with lib.types; attrsOf (submodule networkVolume); description = '' @@ -93,6 +90,8 @@ in }; config = lib.mkIf (cfg.networks != { }) { - systemd.services = lib.mapAttrs' (n: v: lib.nameValuePair "${cfg.backend}-network-${n}" (mkService n v)) cfg.networks; + systemd.services = lib.mapAttrs' + (n: v: lib.nameValuePair "${cfg.backend}-network-${n}" (mkService n v)) + cfg.networks; }; } diff --git a/modules/nixos/virtualisation/oci-containers/volumes.nix b/modules/nixos/virtualisation/oci-containers/volumes.nix index 647cec7f..fab0169d 100644 --- a/modules/nixos/virtualisation/oci-containers/volumes.nix +++ b/modules/nixos/virtualisation/oci-containers/volumes.nix @@ -12,9 +12,7 @@ let description = '' A list of labels to be attached to the volume at runtime. ''; - example = { - "foo" = "baz"; - }; + example = { "foo" = "baz"; }; }; extraOptions = lib.mkOption { @@ -34,43 +32,44 @@ let }; }; - config.extraOptions = lib.mapAttrsToList (name: value: "--label ${name}=${value}") config.labels; + config.extraOptions = + lib.mapAttrsToList (name: value: "--label ${name}=${value}") + config.labels; }; - mkService = name: value: let - removeScript = - if cfg.backend == "podman" - then "podman volume rm --force ${name}" - else "${cfg.backend} volume rm -f ${name}"; + mkService = name: value: + let + removeScript = if cfg.backend == "podman" then + "podman volume rm --force ${name}" + else + "${cfg.backend} volume rm -f ${name}"; - preStartScript = pkgs.writeShellScript "pre-start-oci-container-volume-${name}" '' - ${removeScript} - ''; - in { - path = - if cfg.backend == "docker" then [ config.virtualisation.docker.package ] - else if cfg.backend == "podman" then [ config.virtualisation.podman.package ] - else throw "Unhandled backend: ${cfg.backend}"; - script = lib.concatStringsSep " \\\n " ([ - "exec ${cfg.backend} " - ] ++ (map escapeShellArg value.preRunExtraOptions) ++ [ - "volume create" - ] ++ (map escapeShellArg value.extraOptions) ++ [ - name - ]); - postStop = removeScript; + preStartScript = + pkgs.writeShellScript "pre-start-oci-container-volume-${name}" '' + ${removeScript} + ''; + in { + path = if cfg.backend == "docker" then + [ config.virtualisation.docker.package ] + else if cfg.backend == "podman" then + [ config.virtualisation.podman.package ] + else + throw "Unhandled backend: ${cfg.backend}"; + script = lib.concatStringsSep " \\\n " ([ "exec ${cfg.backend} " ] + ++ (map escapeShellArg value.preRunExtraOptions) ++ [ "volume create" ] + ++ (map escapeShellArg value.extraOptions) ++ [ name ]); + postStop = removeScript; - serviceConfig = { - ExecStartPre = [ preStartScript ]; - Type = "oneshot"; - RemainAfterExit = true; + serviceConfig = { + ExecStartPre = [ preStartScript ]; + Type = "oneshot"; + RemainAfterExit = true; + }; + + before = [ "multi-user.target" ]; + wantedBy = [ "multi-user.target" ]; }; - - before = [ "multi-user.target" ]; - wantedBy = [ "multi-user.target" ]; - }; -in -{ +in { options.virtualisation.oci-containers.volumes = lib.mkOption { type = with lib.types; attrsOf (submodule volumeModule); description = '' @@ -84,6 +83,8 @@ in }; config = lib.mkIf (cfg.volumes != { }) { - systemd.services = lib.mapAttrs' (n: v: lib.nameValuePair "${cfg.backend}-volume-${n}" (mkService n v)) cfg.volumes; + systemd.services = lib.mapAttrs' + (n: v: lib.nameValuePair "${cfg.backend}-volume-${n}" (mkService n v)) + cfg.volumes; }; } diff --git a/modules/nixos/xdg/mime-desktop-specific.nix b/modules/nixos/xdg/mime-desktop-specific.nix index 013a40a8..c73c7eb3 100644 --- a/modules/nixos/xdg/mime-desktop-specific.nix +++ b/modules/nixos/xdg/mime-desktop-specific.nix @@ -4,19 +4,17 @@ let cfg = config.xdg.mime; mkMimeSource = name: value: - lib.nameValuePair - "xdg/${name}-mimeapps.list" - (lib.mkIf (value.defaultApplications != { }) { - text = lib.generators.toINI { } { - "Default Applications" = value.defaultApplications; - }; - }); + lib.nameValuePair "xdg/${name}-mimeapps.list" + (lib.mkIf (value.defaultApplications != { }) { + text = lib.generators.toINI { } { + "Default Applications" = value.defaultApplications; + }; + }); xdgMimeAssociations = { name, lib, ... }: { options.defaultApplications = options.xdg.mime.defaultApplications; }; -in -{ +in { options.xdg.mime.desktops = lib.mkOption { type = with lib.types; attrsOf (submodule xdgMimeAssociations); description = '' @@ -29,14 +27,11 @@ in ''; default = { }; example = { - gnome.defaultApplications = { - "application/pdf" = "firefox.desktop"; - }; + gnome.defaultApplications = { "application/pdf" = "firefox.desktop"; }; }; }; config = lib.mkIf (cfg.desktops != { }) { - environment.etc = - lib.mapAttrs' mkMimeSource cfg.desktops; + environment.etc = lib.mapAttrs' mkMimeSource cfg.desktops; }; } diff --git a/modules/nixvim/_private/default.nix b/modules/nixvim/_private/default.nix index af907387..9457fdac 100644 --- a/modules/nixvim/_private/default.nix +++ b/modules/nixvim/_private/default.nix @@ -1,5 +1 @@ -{ - imports = [ - ./extra-arguments.nix - ]; -} +{ imports = [ ./extra-arguments.nix ]; } diff --git a/modules/nixvim/_private/extra-arguments.nix b/modules/nixvim/_private/extra-arguments.nix index cb0908ab..3b319564 100644 --- a/modules/nixvim/_private/extra-arguments.nix +++ b/modules/nixvim/_private/extra-arguments.nix @@ -1,12 +1,12 @@ # All of the extra module arguments to be passed as part of NixVim module. { options, config, lib, pkgs, ... }: -let - foodogsquaredLib = import ../../../lib { inherit pkgs; }; -in -{ - _module.args.foodogsquaredLib = - foodogsquaredLib.extend (final: prev: { - nixvim = import ../../../lib/env-specific/nixvim.nix { inherit pkgs lib; self = final; }; - }); +let foodogsquaredLib = import ../../../lib { inherit pkgs; }; +in { + _module.args.foodogsquaredLib = foodogsquaredLib.extend (final: prev: { + nixvim = import ../../../lib/env-specific/nixvim.nix { + inherit pkgs lib; + self = final; + }; + }); } diff --git a/modules/nixvim/keyunmaps.nix b/modules/nixvim/keyunmaps.nix index a76e554c..cc664971 100644 --- a/modules/nixvim/keyunmaps.nix +++ b/modules/nixvim/keyunmaps.nix @@ -35,18 +35,15 @@ let }; }; }; -in -{ +in { options.keyunmaps = lib.mkOption { type = with lib.types; listOf (submodule keyunmapOption); default = [ ]; - example = [ - { - modes = [ "n" "i" ]; - key = "w"; - options.buffer = true; - } - ]; + example = [{ + modes = [ "n" "i" ]; + key = "w"; + options.buffer = true; + }]; description = '' A list of keymaps to be removed. Take note, this will occur after setting the keymap. diff --git a/modules/nixvim/plugins/dressing-nvim.nix b/modules/nixvim/plugins/dressing-nvim.nix index 31294eaf..b5dd8edf 100644 --- a/modules/nixvim/plugins/dressing-nvim.nix +++ b/modules/nixvim/plugins/dressing-nvim.nix @@ -1,9 +1,7 @@ { config, lib, pkgs, helpers, ... }: -let - cfg = config.plugins.dressing-nvim; -in -{ +let cfg = config.plugins.dressing-nvim; +in { options.plugins.dressing-nvim = { enable = lib.mkEnableOption "dressing.nvim configuration"; diff --git a/modules/nixvim/plugins/legendary-nvim.nix b/modules/nixvim/plugins/legendary-nvim.nix index 26c01f4b..3c1eaa33 100644 --- a/modules/nixvim/plugins/legendary-nvim.nix +++ b/modules/nixvim/plugins/legendary-nvim.nix @@ -4,14 +4,14 @@ let cfg = config.plugins.legendary-nvim; mkEnableOption' = desc: lib.mkEnableOption desc // { default = true; }; -in -{ +in { options.plugins.legendary-nvim = { enable = lib.mkEnableOption "legendary.nvim"; package = lib.mkPackageOption pkgs [ "vimPlugins" "legendary-nvim" ] { }; - additionalSetup = mkEnableOption' "dependencies for additional features like frecency sorting"; + additionalSetup = mkEnableOption' + "dependencies for additional features like frecency sorting"; integrations = { nvim-tree.enable = @@ -27,26 +27,21 @@ in freeformType = with lib.types; attrsOf anything; config = lib.mkMerge [ - (lib.mkIf - ( - config.plugins.nvim-tree.enable && cfg.integrations.nvim-tree.enable - ) - { extensions.nvim_tree = true; }) - (lib.mkIf - ( - config.plugins.smart-splits.enable && cfg.integrations.smart-splits.enable - ) - { + (lib.mkIf (config.plugins.nvim-tree.enable + && cfg.integrations.nvim-tree.enable) { + extensions.nvim_tree = true; + }) + (lib.mkIf (config.plugins.smart-splits.enable + && cfg.integrations.smart-splits.enable) { extensions.smart_splits = { directions = [ "h" "j" "k" "l" ]; mods = { }; }; }) - (lib.mkIf - ( - config.plugins.diffview.enable && cfg.integrations.diffview.enable - ) - { extensions.diffview = true; }) + (lib.mkIf (config.plugins.diffview.enable + && cfg.integrations.diffview.enable) { + extensions.diffview = true; + }) ]; }; default = { }; @@ -55,8 +50,7 @@ in }; config = lib.mkIf cfg.enable { - extraPlugins = - [ cfg.package ] + extraPlugins = [ cfg.package ] ++ lib.optional cfg.additionalSetup pkgs.vimPlugins.sqlite-lua; extraPackages = lib.optional cfg.additionalSetup pkgs.sqlite; diff --git a/modules/nixvim/plugins/lush-nvim.nix b/modules/nixvim/plugins/lush-nvim.nix index 1f3b6245..ac8e7768 100644 --- a/modules/nixvim/plugins/lush-nvim.nix +++ b/modules/nixvim/plugins/lush-nvim.nix @@ -30,14 +30,12 @@ let let # Converts each of the highlight group into a function to be able parsed and # used by Lush. - highlightList = - lib.mapAttrsToList - (highlight: arguments: "${highlight}(${helpers.toLuaObject arguments})") - theme.highlights; - in - # This is based from rktjmp/lush-template. We'll improve on things from + highlightList = lib.mapAttrsToList + (highlight: arguments: "${highlight}(${helpers.toLuaObject arguments})") + theme.highlights; + # This is based from rktjmp/lush-template. We'll improve on things from # here whenever necessary. - lib.nameValuePair "colors/${name}.lua" { + in lib.nameValuePair "colors/${name}.lua" { text = '' ${cfg.extraConfigLua} ${theme.extraConfigLua} @@ -58,8 +56,7 @@ let lush(spec) ''; }; -in -{ +in { options.colorschemes.lush = { enable = lib.mkEnableOption "theming with lush.nvim"; @@ -107,7 +104,6 @@ in config = lib.mkIf cfg.enable { extraPlugins = [ cfg.package ]; - extraFiles = - lib.mapAttrs' mkLushColorSchemes cfg.themes; + extraFiles = lib.mapAttrs' mkLushColorSchemes cfg.themes; }; } diff --git a/modules/nixvim/plugins/nvim-config-local.nix b/modules/nixvim/plugins/nvim-config-local.nix index 20366d27..05c8a7ea 100644 --- a/modules/nixvim/plugins/nvim-config-local.nix +++ b/modules/nixvim/plugins/nvim-config-local.nix @@ -1,9 +1,7 @@ { config, lib, pkgs, helpers, ... }: -let - cfg = config.plugins.nvim-config-local; -in -{ +let cfg = config.plugins.nvim-config-local; +in { options.plugins.nvim-config-local = { enable = lib.mkEnableOption "nvim-config-local"; @@ -26,12 +24,11 @@ in }; }; - config = - lib.mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + config = lib.mkIf cfg.enable { + extraPlugins = [ cfg.package ]; - extraConfigLua = '' - require("config-local").setup(${helpers.toLuaConfig cfg.settings}) - ''; - }; + extraConfigLua = '' + require("config-local").setup(${helpers.toLuaConfig cfg.settings}) + ''; + }; } diff --git a/modules/nixvim/plugins/nvim-remote-containers.nix b/modules/nixvim/plugins/nvim-remote-containers.nix index 136b90d8..ee2f3823 100644 --- a/modules/nixvim/plugins/nvim-remote-containers.nix +++ b/modules/nixvim/plugins/nvim-remote-containers.nix @@ -1,13 +1,12 @@ -{ config, lib, pkgs, helpers,... }: +{ config, lib, pkgs, helpers, ... }: -let - cfg = config.plugins.nvim-remote-containers; -in -{ +let cfg = config.plugins.nvim-remote-containers; +in { options.plugins.nvim-remote-containers = { enable = lib.mkEnableOption "nvim-remote-containers"; - package = lib.mkPackageOption pkgs [ "vimPlugins" "nvim-remote-containers" ] { }; + package = + lib.mkPackageOption pkgs [ "vimPlugins" "nvim-remote-containers" ] { }; }; config = lib.mkIf cfg.enable { diff --git a/modules/wrapper-manager/_private/default.nix b/modules/wrapper-manager/_private/default.nix index af907387..9457fdac 100644 --- a/modules/wrapper-manager/_private/default.nix +++ b/modules/wrapper-manager/_private/default.nix @@ -1,5 +1 @@ -{ - imports = [ - ./extra-arguments.nix - ]; -} +{ imports = [ ./extra-arguments.nix ]; } diff --git a/modules/wrapper-manager/_private/extra-arguments.nix b/modules/wrapper-manager/_private/extra-arguments.nix index eceaf0b9..a733e4a2 100644 --- a/modules/wrapper-manager/_private/extra-arguments.nix +++ b/modules/wrapper-manager/_private/extra-arguments.nix @@ -1,12 +1,11 @@ { pkgs, lib, ... }: -let - foodogsquaredLib = import ../../../lib { inherit pkgs; }; -in -{ - _module.args.foodogsquaredLib = - foodogsquaredLib.extend (final: prev: { - wrapper-manager = - import ../../../lib/env-specific/wrapper-manager.nix { inherit pkgs lib; self = final; }; - }); +let foodogsquaredLib = import ../../../lib { inherit pkgs; }; +in { + _module.args.foodogsquaredLib = foodogsquaredLib.extend (final: prev: { + wrapper-manager = import ../../../lib/env-specific/wrapper-manager.nix { + inherit pkgs lib; + self = final; + }; + }); } diff --git a/modules/wrapper-manager/dconf.nix b/modules/wrapper-manager/dconf.nix index fe6aaaea..c76d935f 100644 --- a/modules/wrapper-manager/dconf.nix +++ b/modules/wrapper-manager/dconf.nix @@ -16,30 +16,21 @@ let settingsFormat = { type = with lib.types; let - valueType = (oneOf [ - bool - float - int - str - (listOf valueType) - ]) // { + valueType = (oneOf [ bool float int str (listOf valueType) ]) // { description = "dconf value"; }; - in - attrsOf (attrsOf valueType); + in attrsOf (attrsOf valueType); generate = name: value: pkgs.writeTextDir "/dconf/${name}" (lib.generators.toDconfINI value); }; dconfModuleFactory = { isGlobal ? false }: { - enable = lib.mkEnableOption "configuration with dconf" // lib.optionalAttrs (!isGlobal) { - default = cfg.enable; - }; + enable = lib.mkEnableOption "configuration with dconf" + // lib.optionalAttrs (!isGlobal) { default = cfg.enable; }; - package = lib.mkPackageOption pkgs "dconf" { } // lib.optionalAttrs (!isGlobal) { - default = cfg.package; - }; + package = lib.mkPackageOption pkgs "dconf" { } + // lib.optionalAttrs (!isGlobal) { default = cfg.package; }; settings = lib.mkOption { type = settingsFormat.type; @@ -93,30 +84,30 @@ let ''; }; }; -in -{ +in { options.dconf = dconfModuleFactory { isGlobal = true; }; - options.wrappers = - let - dconfSubmodule = { config, lib, name, ... }: let + options.wrappers = let + dconfSubmodule = { config, lib, name, ... }: + let submoduleCfg = config.dconf; - dconfProfileFile = - pkgs.writeText - "dconf-profile" - (lib.concatMapStrings (db: "${db}\n") submoduleCfg.profile); + dconfProfileFile = pkgs.writeText "dconf-profile" (lib.concatMapStrings + (db: '' + ${db} + '') submoduleCfg.profile); - dconfSettings = - settingsFormat.generate "wrapper-manager-dconf-${config.executableName}-settings" submoduleCfg.settings; + dconfSettings = settingsFormat.generate + "wrapper-manager-dconf-${config.executableName}-settings" + submoduleCfg.settings; keyfilesDir = pkgs.symlinkJoin { name = "wrapper-manager-dconf-${config.executableName}"; paths = submoduleCfg.keyfiles ++ [ "${dconfSettings}/dconf" ]; }; - dconfSettingsDatabase = - pkgs.runCommand "wrapper-manager-dconf-${config.executableName}-database" { + dconfSettingsDatabase = pkgs.runCommand + "wrapper-manager-dconf-${config.executableName}-database" { nativeBuildInputs = [ submoduleCfg.package ]; } '' dconf compile ${builtins.placeholder "out"} "${keyfilesDir}" @@ -148,8 +139,7 @@ in }; }; }; - in - lib.mkOption { - type = with lib.types; attrsOf (submodule dconfSubmodule); - }; + in lib.mkOption { + type = with lib.types; attrsOf (submodule dconfSubmodule); + }; } diff --git a/modules/wrapper-manager/fonts.nix b/modules/wrapper-manager/fonts.nix index 106c0984..aeaa70c4 100644 --- a/modules/wrapper-manager/fonts.nix +++ b/modules/wrapper-manager/fonts.nix @@ -10,13 +10,12 @@ let packages = lib.mkOption { type = with lib.types; listOf package; - description = - if isGlobal then '' - Global list of fonts to be added per wrapper (with the local fonts - support enabled anyways). - '' else '' - List of fonts to be added to the wrapper. - ''; + description = if isGlobal then '' + Global list of fonts to be added per wrapper (with the local fonts + support enabled anyways). + '' else '' + List of fonts to be added to the wrapper. + ''; default = [ ]; example = lib.literalExpression '' with pkgs; [ @@ -28,14 +27,12 @@ let ''; }; }; -in -{ +in { options.fonts = fontsModuleFactory { isGlobal = true; }; - wrappers = - let - fontsSubmodule = { config, lib, name, pkgs, ... }: let - submoduleCfg = config.fonts; + wrappers = let + fontsSubmodule = { config, lib, name, pkgs, ... }: + let submoduleCfg = config.fonts; in { options.fonts = fontsModuleFactory { isGlobal = false; }; @@ -44,11 +41,9 @@ in inherit (pkgs) fontconfig; fontsDirectories = submoduleCfg.packages; }; - in lib.mkIf submoduleCfg.enable { - fonts.packages = cfg.packages; - }; + in lib.mkIf submoduleCfg.enable { fonts.packages = cfg.packages; }; }; - in lib.mkOption { - type = with lib.types; attrsOf (submodule fontsSubmodule); - }; + in lib.mkOption { + type = with lib.types; attrsOf (submodule fontsSubmodule); + }; } diff --git a/modules/wrapper-manager/nixgl.nix b/modules/wrapper-manager/nixgl.nix index afab8a0e..de16cd7f 100644 --- a/modules/wrapper-manager/nixgl.nix +++ b/modules/wrapper-manager/nixgl.nix @@ -4,12 +4,9 @@ let cfg = config.nixgl; nixgl = variant: src: - let - nixgl = import src { inherit pkgs; }; - in - lib.getAttrFromPath variant nixgl; -in -{ + let nixgl = import src { inherit pkgs; }; + in lib.getAttrFromPath variant nixgl; +in { options.nixgl = { enableAll = lib.mkEnableOption "wrapping all wrappers with NixGL"; @@ -64,27 +61,22 @@ in }; }; - options.wrappers = - let - nixglWrapperModule = { config, lib, name, ... }: let - submoduleCfg = config.nixgl; + options.wrappers = let + nixglWrapperModule = { config, lib, name, ... }: + let submoduleCfg = config.nixgl; in { options.nixgl = { enable = lib.mkEnableOption "wrapping NixGL for this wrapper" // { default = cfg.enableAll; }; - src = options.nixgl.src // { - default = cfg.src; - }; + src = options.nixgl.src // { default = cfg.src; }; executable = options.nixgl.executable // { default = lib.getExe (nixgl config.nixgl.variant config.nixgl.src); }; - variant = options.nixgl.variant // { - default = cfg.variant; - }; + variant = options.nixgl.variant // { default = cfg.variant; }; wraparound = { arg0 = lib.mkOption { @@ -113,15 +105,15 @@ in }; config = lib.mkIf config.nixgl.enable { - arg0 = - if submoduleCfg.executable == null - then lib.getExe (nixgl config.nixgl.variant config.nixgl.src) - else submoduleCfg.executable; - prependArgs = lib.mkBefore ([ submoduleCfg.wraparound.arg0 ] ++ submoduleCfg.wraparound.extraArgs); + arg0 = if submoduleCfg.executable == null then + lib.getExe (nixgl config.nixgl.variant config.nixgl.src) + else + submoduleCfg.executable; + prependArgs = lib.mkBefore ([ submoduleCfg.wraparound.arg0 ] + ++ submoduleCfg.wraparound.extraArgs); }; }; - in - lib.mkOption { - type = lib.types.attrsOf (lib.types.submodule nixglWrapperModule); - }; + in lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule nixglWrapperModule); + }; } diff --git a/modules/wrapper-manager/programs/blender.nix b/modules/wrapper-manager/programs/blender.nix index d533d75d..69477f00 100644 --- a/modules/wrapper-manager/programs/blender.nix +++ b/modules/wrapper-manager/programs/blender.nix @@ -4,24 +4,21 @@ let cfg = config.programs.blender; blenderVersion = lib.versions.majorMinor cfg.package.version; - addons = - pkgs.runCommand "blender-system-resources" - { - passAsFile = [ "paths" ]; - paths = cfg.addons ++ [ cfg.package ]; - nativeBuildInputs = with pkgs; [ outils ]; - } '' - mkdir -p $out - for i in $(cat $pathsPath); do - resourcesPath="$i/share/blender" - if [ -d $i/share/blender/${blenderVersion} ]; then - resourcesPath="$i/share/blender/${blenderVersion}"; - fi - lndir -silent $resourcesPath $out - done - ''; -in -{ + addons = pkgs.runCommand "blender-system-resources" { + passAsFile = [ "paths" ]; + paths = cfg.addons ++ [ cfg.package ]; + nativeBuildInputs = with pkgs; [ outils ]; + } '' + mkdir -p $out + for i in $(cat $pathsPath); do + resourcesPath="$i/share/blender" + if [ -d $i/share/blender/${blenderVersion} ]; then + resourcesPath="$i/share/blender/${blenderVersion}"; + fi + lndir -silent $resourcesPath $out + done + ''; +in { options.programs.blender = { enable = lib.mkEnableOption "Blender, a 3D computer graphics tool"; @@ -55,9 +52,7 @@ in { basePackages = [ cfg.package ]; - wrappers.blender = { - arg0 = lib.getExe' cfg.package "blender"; - }; + wrappers.blender = { arg0 = lib.getExe' cfg.package "blender"; }; } (lib.mkIf (builtins.length cfg.addons > 0) { diff --git a/modules/wrapper-manager/programs/jujutsu.nix b/modules/wrapper-manager/programs/jujutsu.nix index 1bc8eb4b..8ac0f4b7 100644 --- a/modules/wrapper-manager/programs/jujutsu.nix +++ b/modules/wrapper-manager/programs/jujutsu.nix @@ -4,8 +4,7 @@ let cfg = config.programs.jujutsu; settingsFormat = pkgs.formats.toml { }; -in -{ +in { options.programs.jujutsu = { enable = lib.mkEnableOption "Jujutsu, a Git-compatible DVCS"; diff --git a/modules/wrapper-manager/programs/neovim.nix b/modules/wrapper-manager/programs/neovim.nix index 7c379bf1..8f690b14 100644 --- a/modules/wrapper-manager/programs/neovim.nix +++ b/modules/wrapper-manager/programs/neovim.nix @@ -36,8 +36,7 @@ let }; finalNeovimPackage = pkgs.wrapNeovimUnstable cfg.package neovimConfig; -in -{ +in { options.programs.neovim = { enable = lib.mkEnableOption "Neovim, a terminal text editor"; diff --git a/modules/wrapper-manager/programs/tmux.nix b/modules/wrapper-manager/programs/tmux.nix index 0cf2c177..597c92bd 100644 --- a/modules/wrapper-manager/programs/tmux.nix +++ b/modules/wrapper-manager/programs/tmux.nix @@ -1,9 +1,7 @@ { config, lib, pkgs, ... }: -let - cfg = config.programs.tmux; -in -{ +let cfg = config.programs.tmux; +in { options.programs.tmux = { enable = lib.mkEnableOption "configuring a tmux wrapper"; diff --git a/modules/wrapper-manager/programs/zellij.nix b/modules/wrapper-manager/programs/zellij.nix index b273f22e..6688dd7b 100644 --- a/modules/wrapper-manager/programs/zellij.nix +++ b/modules/wrapper-manager/programs/zellij.nix @@ -1,9 +1,7 @@ { lib, pkgs, config, ... }: -let - cfg = config.programs.zellij; -in -{ +let cfg = config.programs.zellij; +in { options.programs.zellij = { enable = lib.mkEnableOption "Zellij, a terminal multiplexer"; diff --git a/modules/wrapper-manager/wraparound/boxxy.nix b/modules/wrapper-manager/wraparound/boxxy.nix index 6f9a322d..105d29c8 100644 --- a/modules/wrapper-manager/wraparound/boxxy.nix +++ b/modules/wrapper-manager/wraparound/boxxy.nix @@ -34,9 +34,8 @@ let }; boxxyModuleFactory = { isGlobal ? false }: { - package = lib.mkPackageOption pkgs "boxxy" { } // lib.optionalAttrs (!isGlobal) { - default = cfg.package; - }; + package = lib.mkPackageOption pkgs "boxxy" { } + // lib.optionalAttrs (!isGlobal) { default = cfg.package; }; # TODO: Perhaps, consider creating a PR to upstream repo to pass a config file? # Boxxy doesn't have a way to pass a custom configuration file so we're @@ -73,49 +72,38 @@ let example = [ "--immutable" "--daemon" ]; }; }; -in -{ +in { options.wraparound.boxxy = boxxyModuleFactory { isGlobal = true; }; - options.wrappers = - let - boxxySandboxModule = { name, lib, config, pkgs, ... }: - let - submoduleCfg = config.wraparound.boxxy; - in - { - options.wraparound.variant = lib.mkOption { - type = with lib.types; nullOr (enum [ "boxxy" ]); - }; + options.wrappers = let + boxxySandboxModule = { name, lib, config, pkgs, ... }: + let submoduleCfg = config.wraparound.boxxy; + in { + options.wraparound.variant = + lib.mkOption { type = with lib.types; nullOr (enum [ "boxxy" ]); }; - options.wraparound.boxxy = boxxyModuleFactory { isGlobal = false; }; + options.wraparound.boxxy = boxxyModuleFactory { isGlobal = false; }; - config = lib.mkIf (config.wraparound.variant == "boxxy") { - wraparound.boxxy.rules = cfg.rules; + config = lib.mkIf (config.wraparound.variant == "boxxy") { + wraparound.boxxy.rules = cfg.rules; - wraparound.boxxy.extraArgs = - cfg.extraArgs - ++ (lib.mapAttrsToList - (_: metadata: - let - inherit (metadata) source destination mode; - ruleArg = - if mode != null - then "${source}:${destination}:${mode}" - else "${source}:${destination}"; - in - "--rule ${ruleArg}") - submoduleCfg.rules); + wraparound.boxxy.extraArgs = cfg.extraArgs ++ (lib.mapAttrsToList + (_: metadata: + let + inherit (metadata) source destination mode; + ruleArg = if mode != null then + "${source}:${destination}:${mode}" + else + "${source}:${destination}"; + in "--rule ${ruleArg}") submoduleCfg.rules); - arg0 = lib.getExe' submoduleCfg.package "boxxy"; - prependArgs = lib.mkBefore - (submoduleCfg.extraArgs - ++ [ "--" config.wraparound.subwrapper.arg0 ] - ++ config.wraparound.subwrapper.extraArgs); - }; + arg0 = lib.getExe' submoduleCfg.package "boxxy"; + prependArgs = lib.mkBefore (submoduleCfg.extraArgs + ++ [ "--" config.wraparound.subwrapper.arg0 ] + ++ config.wraparound.subwrapper.extraArgs); }; - in - lib.mkOption { - type = with lib.types; attrsOf (submodule boxxySandboxModule); - }; + }; + in lib.mkOption { + type = with lib.types; attrsOf (submodule boxxySandboxModule); + }; } diff --git a/modules/wrapper-manager/wraparound/bubblewrap/dbus-filter.nix b/modules/wrapper-manager/wraparound/bubblewrap/dbus-filter.nix index f070ef9c..244a3e58 100644 --- a/modules/wrapper-manager/wraparound/bubblewrap/dbus-filter.nix +++ b/modules/wrapper-manager/wraparound/bubblewrap/dbus-filter.nix @@ -7,10 +7,8 @@ let cfg = config.wraparound.bubblewrap; dbusFilterType = { lib, ... }: - let - ruleBasedPoliciesType = with lib.types; listOf str; - in - { + let ruleBasedPoliciesType = with lib.types; listOf str; + in { options = { level = lib.mkOption { type = with lib.types; nullOr (enum [ "see" "talk" "own" ]); @@ -48,141 +46,127 @@ let }; filter = { - package = lib.mkPackageOption pkgs "xdg-dbus-proxy" { } // lib.optionalAttrs isGlobal { - default = cfg.filter.package; - }; + package = lib.mkPackageOption pkgs "xdg-dbus-proxy" { } + // lib.optionalAttrs isGlobal { default = cfg.filter.package; }; }; }; }; -in -{ +in { options.wraparound.bubblewrap = - lib.recursiveUpdate - (bubblewrapModuleFactory { isGlobal = true; }) - { - dbus.filter.policies = lib.mkOption { - type = with lib.types; attrsOf (submodule dbusFilterType); + lib.recursiveUpdate (bubblewrapModuleFactory { isGlobal = true; }) { + dbus.filter.policies = lib.mkOption { + type = with lib.types; attrsOf (submodule dbusFilterType); + description = '' + A global set of D-Bus addresses with their policies set with + {command}`xdg-dbus-proxy` for each D-Bus address specified on the + Bubblewrap-enabled wrappers. See {manpage}`xdg-dbus-proxy(1)` for + more details. + ''; + default = { }; + example = { + "org.systemd.Systemd".level = "talk"; + "org.example.*".level = "own"; + "org.foo.Bar" = { + call = [ "*" ]; + broadcast = [ ]; + }; + }; + }; + }; + + options.wrappers = let + addressesModule = { config, lib, name, ... }: { + options = { + path = lib.mkOption { + type = lib.types.str; + default = + "$XDG_RUNTIME_DIR/wrapper-manager-fds/$(echo $RANDOM | base64)"; description = '' - A global set of D-Bus addresses with their policies set with - {command}`xdg-dbus-proxy` for each D-Bus address specified on the - Bubblewrap-enabled wrappers. See {manpage}`xdg-dbus-proxy(1)` for - more details. + Path of the unix socket domain. A value of `null` means + the launcher takes care of it. + ''; + }; + + policies = lib.mkOption { + type = lib.types.submodule dbusFilterType; + description = '' + Policies to be set to that address. ''; default = { }; - example = { - "org.systemd.Systemd".level = "talk"; - "org.example.*".level = "own"; - "org.foo.Bar" = { - call = [ "*" ]; - broadcast = [ ]; - }; - }; + example = { level = "see"; }; + }; + + extraArgs = lib.mkOption { + type = with lib.types; listOf str; + description = '' + List of proxy-specific arguments to be passed to + {command}`xdg-dbus-proxy`. + ''; + default = [ ]; }; }; - options.wrappers = - let - addressesModule = { config, lib, name, ... }: { - options = { - path = lib.mkOption { - type = lib.types.str; - default = "$XDG_RUNTIME_DIR/wrapper-manager-fds/$(echo $RANDOM | base64)"; - description = '' - Path of the unix socket domain. A value of `null` means - the launcher takes care of it. - ''; - }; + config.policies = cfg.dbus.filter.policies; + config.extraArgs = let inherit (config) policies; + in lib.optionals (policies.level != null) + [ "--${policies.level}=${name}" ] + ++ builtins.map (rule: "--call=${name}=${rule}") policies.call + ++ builtins.map (rule: "--broadcast=${name}=${rule}") policies.broadcast; + }; - policies = lib.mkOption { - type = lib.types.submodule dbusFilterType; - description = '' - Policies to be set to that address. - ''; - default = { }; - example = { - level = "see"; - }; - }; + bubblewrapModule = { config, lib, pkgs, name, ... }: + let submoduleCfg = config.wraparound.bubblewrap; + in { + options.wraparound.bubblewrap = + lib.recursiveUpdate (bubblewrapModuleFactory { isGlobal = false; }) { + dbus.filter = { + extraArgs = lib.mkOption { + type = with lib.types; listOf str; + description = '' + List of arguments to be passed to {command}`xdg-dbus-proxy`. + ''; + default = [ ]; + }; - extraArgs = lib.mkOption { - type = with lib.types; listOf str; - description = '' - List of proxy-specific arguments to be passed to - {command}`xdg-dbus-proxy`. - ''; - default = [ ]; - }; - }; + bwrapArgs = lib.mkOption { + type = with lib.types; listOf str; + description = '' + List of arguments to be passed to the Bubblewrap + environment of the D-Bus proxy. + ''; + default = [ ]; + }; - config.policies = cfg.dbus.filter.policies; - config.extraArgs = - let - inherit (config) policies; - in - lib.optionals (policies.level != null) [ "--${policies.level}=${name}" ] - ++ builtins.map (rule: "--call=${name}=${rule}") policies.call - ++ builtins.map (rule: "--broadcast=${name}=${rule}") policies.broadcast; - }; - - bubblewrapModule = { config, lib, pkgs, name, ... }: - let - submoduleCfg = config.wraparound.bubblewrap; - in - { - options.wraparound.bubblewrap = - lib.recursiveUpdate - (bubblewrapModuleFactory { isGlobal = false; }) - { - dbus.filter = { - extraArgs = lib.mkOption { - type = with lib.types; listOf str; - description = '' - List of arguments to be passed to {command}`xdg-dbus-proxy`. - ''; - default = [ ]; - }; - - bwrapArgs = lib.mkOption { - type = with lib.types; listOf str; - description = '' - List of arguments to be passed to the Bubblewrap - environment of the D-Bus proxy. - ''; - default = [ ]; - }; - - addresses = lib.mkOption { - type = with lib.types; attrsOf (submodule addressesModule); - description = '' - A set of addresses to be applied with the filter through - {command}`xdg-dbus-proxy`. - ''; - default = { }; - example = { - "org.example.Bar".policies.level = "talk"; - "org.freedesktop.systemd1".policies.level = "talk"; - "org.gtk.vfs.*".policies.level = "talk"; - "org.gtk.vfs".policies.level = "talk"; - }; - }; - }; + addresses = lib.mkOption { + type = with lib.types; attrsOf (submodule addressesModule); + description = '' + A set of addresses to be applied with the filter through + {command}`xdg-dbus-proxy`. + ''; + default = { }; + example = { + "org.example.Bar".policies.level = "talk"; + "org.freedesktop.systemd1".policies.level = "talk"; + "org.gtk.vfs.*".policies.level = "talk"; + "org.gtk.vfs".policies.level = "talk"; }; - - config = lib.mkIf (config.wraparound.variant == "bubblewrap") { - wraparound.bubblewrap.dbus.filter.extraArgs = - let - makeDbusProxyArgs = address: metadata: - [ address (builtins.toString metadata.path) ] ++ metadata.extraArgs; - in - lib.lists.flatten (lib.mapAttrsToList makeDbusProxyArgs submoduleCfg.dbus.filter.addresses); - - wraparound.bubblewrap.sharedNixPaths = [ - submoduleCfg.dbus.filter.package - ]; }; }; - in - lib.mkOption { - type = with lib.types; attrsOf (submodule bubblewrapModule); + }; + + config = lib.mkIf (config.wraparound.variant == "bubblewrap") { + wraparound.bubblewrap.dbus.filter.extraArgs = let + makeDbusProxyArgs = address: metadata: + [ address (builtins.toString metadata.path) ] + ++ metadata.extraArgs; + in lib.lists.flatten (lib.mapAttrsToList makeDbusProxyArgs + submoduleCfg.dbus.filter.addresses); + + wraparound.bubblewrap.sharedNixPaths = + [ submoduleCfg.dbus.filter.package ]; + }; }; + in lib.mkOption { + type = with lib.types; attrsOf (submodule bubblewrapModule); + }; } diff --git a/modules/wrapper-manager/wraparound/bubblewrap/default.nix b/modules/wrapper-manager/wraparound/bubblewrap/default.nix index b8b6da1a..d58987dc 100644 --- a/modules/wrapper-manager/wraparound/bubblewrap/default.nix +++ b/modules/wrapper-manager/wraparound/bubblewrap/default.nix @@ -21,78 +21,73 @@ let cfg = config.wraparound.bubblewrap; bubblewrapModuleFactory = { isGlobal ? false }: { - package = lib.mkPackageOption pkgs "bubblewrap" { } // lib.optionalAttrs isGlobal { - default = cfg.package; - }; + package = lib.mkPackageOption pkgs "bubblewrap" { } + // lib.optionalAttrs isGlobal { default = cfg.package; }; extraArgs = lib.mkOption { type = with lib.types; listOf str; default = [ ]; - description = - if isGlobal - then '' - Global list of extra arguments to be given to all Bubblewrap-enabled - wrappers. - '' - else '' - List of extra arguments to be given to the Bubblewrap executable. - ''; + description = if isGlobal then '' + Global list of extra arguments to be given to all Bubblewrap-enabled + wrappers. + '' else '' + List of extra arguments to be given to the Bubblewrap executable. + ''; }; enableNetwork = lib.mkEnableOption "sharing of the host network" // { default = if isGlobal then true else cfg.enableNetwork; }; - enableBundledCertificates = lib.mkEnableOption "bundling additional certificates from nixpkgs" // { - default = if isGlobal then true else cfg.enableBundledCertificates; - }; + enableBundledCertificates = + lib.mkEnableOption "bundling additional certificates from nixpkgs" // { + default = if isGlobal then true else cfg.enableBundledCertificates; + }; enableIsolation = lib.mkEnableOption "unsharing most of the system" // { default = if isGlobal then true else cfg.enableIsolation; }; - enableEnsureChildDiesWithParent = lib.mkEnableOption "ensuring child processes die with parent" // { - default = if isGlobal then true else cfg.enableEnsureChildDiesWithParent; - }; + enableEnsureChildDiesWithParent = + lib.mkEnableOption "ensuring child processes die with parent" // { + default = + if isGlobal then true else cfg.enableEnsureChildDiesWithParent; + }; }; -in -{ - imports = [ - ./launcher.nix - ./dbus-filter.nix - ./filesystem.nix - ]; +in { + imports = [ ./launcher.nix ./dbus-filter.nix ./filesystem.nix ]; options.wraparound.bubblewrap = bubblewrapModuleFactory { isGlobal = true; }; - options.wrappers = - let - bubblewrapModule = { name, config, lib, ... }: - let - submoduleCfg = config.wraparound.bubblewrap; - env' = lib.filterAttrs (n: _: !(lib.strings.hasPrefix "WRAPPER_MANAGER_BWRAP_LAUNCHER" n)) config.env; - in - { - options.wraparound.variant = lib.mkOption { - type = with lib.types; nullOr (enum [ "bubblewrap" ]); - }; + options.wrappers = let + bubblewrapModule = { name, config, lib, ... }: + let + submoduleCfg = config.wraparound.bubblewrap; + env' = lib.filterAttrs + (n: _: !(lib.strings.hasPrefix "WRAPPER_MANAGER_BWRAP_LAUNCHER" n)) + config.env; + in { + options.wraparound.variant = lib.mkOption { + type = with lib.types; nullOr (enum [ "bubblewrap" ]); + }; - options.wraparound.bubblewrap = bubblewrapModuleFactory { isGlobal = false; }; + options.wraparound.bubblewrap = + bubblewrapModuleFactory { isGlobal = false; }; - config = lib.mkIf (config.wraparound.variant == "bubblewrap") (lib.mkMerge [ + config = lib.mkIf (config.wraparound.variant == "bubblewrap") + (lib.mkMerge [ { # Ordering of the arguments here matter(?). - wraparound.bubblewrap.extraArgs = - cfg.extraArgs - ++ lib.mapAttrsToList - (var: metadata: - if metadata.action == "unset" then - "--unsetenv ${var}" - else if lib.elem metadata.action [ "prefix" "suffix" ] then - "--setenv ${var} ${lib.concatStringsSep metadata.separator metadata.value}" - else - "--setenv ${var} ${metadata.value}") - env'; + wraparound.bubblewrap.extraArgs = cfg.extraArgs + ++ lib.mapAttrsToList (var: metadata: + if metadata.action == "unset" then + "--unsetenv ${var}" + else if lib.elem metadata.action [ "prefix" "suffix" ] then + "--setenv ${var} ${ + lib.concatStringsSep metadata.separator metadata.value + }" + else + "--setenv ${var} ${metadata.value}") env'; } (lib.mkIf submoduleCfg.enableNetwork { @@ -103,12 +98,8 @@ in # The most common network-related files found on most # distributions. This should be enough in most cases. If not, # we'll probably let the launcher handle this. - wraparound.bubblewrap.binds.ro = [ - "/etc/ssh" - "/etc/ssl" - "/etc/hosts" - "/etc/resolv.conf" - ]; + wraparound.bubblewrap.binds.ro = + [ "/etc/ssh" "/etc/ssl" "/etc/hosts" "/etc/resolv.conf" ]; }) (lib.mkIf submoduleCfg.enableBundledCertificates { @@ -120,16 +111,17 @@ in }) (lib.mkIf submoduleCfg.enableIsolation { - wraparound.bubblewrap.extraArgs = lib.mkBefore [ "--unshare-all" ]; + wraparound.bubblewrap.extraArgs = + lib.mkBefore [ "--unshare-all" ]; }) (lib.mkIf submoduleCfg.enableEnsureChildDiesWithParent { - wraparound.bubblewrap.extraArgs = lib.mkBefore [ "--die-with-parent" ]; + wraparound.bubblewrap.extraArgs = + lib.mkBefore [ "--die-with-parent" ]; }) ]); - }; - in - lib.mkOption { - type = with lib.types; attrsOf (submodule bubblewrapModule); - }; + }; + in lib.mkOption { + type = with lib.types; attrsOf (submodule bubblewrapModule); + }; } diff --git a/modules/wrapper-manager/wraparound/bubblewrap/filesystem.nix b/modules/wrapper-manager/wraparound/bubblewrap/filesystem.nix index 90dee7a7..4a836f41 100644 --- a/modules/wrapper-manager/wraparound/bubblewrap/filesystem.nix +++ b/modules/wrapper-manager/wraparound/bubblewrap/filesystem.nix @@ -6,170 +6,160 @@ let cfg = config.wraparound.bubblewrap; - fileOperationsWithPerms = [ - "file" "dir" "remount-ro" - "bind-data" "ro-bind-data" - ]; + fileOperationsWithPerms = + [ "file" "dir" "remount-ro" "bind-data" "ro-bind-data" ]; fileOperationsWithoutPerms = [ "symlink" - "bind" "bind-try" - "dev-bind" "dev-bind-try" - "ro-bind" "ro-bind-try" + "bind" + "bind-try" + "dev-bind" + "dev-bind-try" + "ro-bind" + "ro-bind-try" ]; - bubblewrapModuleFactory = { isGlobal ? false }: let - filesystemSubmodule = { config, lib, name, ... }: { - options = { - source = lib.mkOption { - type = lib.types.str; - description = '' - The source of the path to be copied from. - ''; - example = lib.literalExpression "./files/example.file"; - }; + bubblewrapModuleFactory = { isGlobal ? false }: + let + filesystemSubmodule = { config, lib, name, ... }: { + options = { + source = lib.mkOption { + type = lib.types.str; + description = '' + The source of the path to be copied from. + ''; + example = lib.literalExpression "./files/example.file"; + }; - destination = lib.mkOption { - type = lib.types.str; - description = '' - The source of the path to be copied from. - ''; - default = name; - example = lib.literalExpression "./files/example.file"; - }; + destination = lib.mkOption { + type = lib.types.str; + description = '' + The source of the path to be copied from. + ''; + default = name; + example = lib.literalExpression "./files/example.file"; + }; - permissions = lib.mkOption { - type = with lib.types; nullOr (strMatching "[0-7]{0,4}"); - description = '' - The permissions of the node in octal. If the value is `null`, it - will be handled by Bubblewrap executable. For more details for each - operation, see {manpage}`bwrap(1)`. - ''; - default = null; - example = "0755"; - }; + permissions = lib.mkOption { + type = with lib.types; nullOr (strMatching "[0-7]{0,4}"); + description = '' + The permissions of the node in octal. If the value is `null`, it + will be handled by Bubblewrap executable. For more details for each + operation, see {manpage}`bwrap(1)`. + ''; + default = null; + example = "0755"; + }; - operation = lib.mkOption { - type = lib.types.enum (fileOperationsWithPerms ++ fileOperationsWithoutPerms); - description = '' - Specify what filesystem-related operations to be done for the given - filesystem object. Only certain operations accept permissions given - from {option}`wraparound.bubblewrap.filesystem..permissions`. - ''; - default = "ro-bind-try"; - example = "bind"; - }; + operation = lib.mkOption { + type = lib.types.enum + (fileOperationsWithPerms ++ fileOperationsWithoutPerms); + description = '' + Specify what filesystem-related operations to be done for the given + filesystem object. Only certain operations accept permissions given + from {option}`wraparound.bubblewrap.filesystem..permissions`. + ''; + default = "ro-bind-try"; + example = "bind"; + }; - lock = lib.mkEnableOption "locking the file"; + lock = lib.mkEnableOption "locking the file"; + }; }; - }; - bindsType = with lib.types; listOf (oneOf [ str package ]); - in { - enableSharedNixStore = lib.mkEnableOption null // { - default = if isGlobal then true else cfg.enableSharedNixStore; - description = '' - Whether to share the entire Nix store directory. - ''; - }; + bindsType = with lib.types; listOf (oneOf [ str package ]); + in { + enableSharedNixStore = lib.mkEnableOption null // { + default = if isGlobal then true else cfg.enableSharedNixStore; + description = '' + Whether to share the entire Nix store directory. + ''; + }; - sharedNixPaths = lib.mkOption { - type = with lib.types; listOf package; - default = [ ]; - description = if isGlobal then '' - A global list of store paths (including its dependencies) to be shared - per-Bubblewrap-enabled-wrappers. - '' else '' - A list of store paths to be mounted (as read-only bind-mounts). Note - that this also includes the listed store objects' dependencies. - ''; - example = lib.literalExpression '' - with pkgs; [ - gtk3 - ] - ''; - }; - - binds = { - ro = lib.mkOption { - type = bindsType; + sharedNixPaths = lib.mkOption { + type = with lib.types; listOf package; default = [ ]; - description = - if isGlobal - then '' + description = if isGlobal then '' + A global list of store paths (including its dependencies) to be shared + per-Bubblewrap-enabled-wrappers. + '' else '' + A list of store paths to be mounted (as read-only bind-mounts). Note + that this also includes the listed store objects' dependencies. + ''; + example = lib.literalExpression '' + with pkgs; [ + gtk3 + ] + ''; + }; + + binds = { + ro = lib.mkOption { + type = bindsType; + default = [ ]; + description = if isGlobal then '' Global list of read-only mounts to be given to all Bubblewrap-enabled wrappers. - '' - else '' + '' else '' List of read-only mounts to the Bubblewrap environment. ''; - example = [ - "/etc/resolv.conf" - "/etc/ssh" - ]; - }; + example = [ "/etc/resolv.conf" "/etc/ssh" ]; + }; - rw = lib.mkOption { - type = bindsType; - default = [ ]; - description = - if isGlobal - then '' + rw = lib.mkOption { + type = bindsType; + default = [ ]; + description = if isGlobal then '' Global list of read-write mounts to be given to all Bubblewrap-enabled wrappers. - '' - else '' + '' else '' List of read-write mounts to the Bubblewrap environment. ''; - }; + }; - dev = lib.mkOption { - type = bindsType; - default = [ ]; - description = - if isGlobal - then '' + dev = lib.mkOption { + type = bindsType; + default = [ ]; + description = if isGlobal then '' Global list of devices to be mounted to all Bubblewrap-enabled wrappers. - '' - else '' + '' else '' List of devices to be mounted inside of the Bubblewrap environment. ''; + }; }; - }; - filesystem = lib.mkOption { - type = with lib.types; attrsOf (submodule filesystemSubmodule); - description = - if isGlobal then '' + filesystem = lib.mkOption { + type = with lib.types; attrsOf (submodule filesystemSubmodule); + description = if isGlobal then '' Set of filesystem configurations to be copied to per-wrapper. '' else '' Set of wrapper-specific filesystem configurations in the Bubblewrap environment. ''; - default = { }; - example = lib.literalExpression '' - { - "/etc/hello" = { - source = ./files/hello; - permissions = "0700"; - operation = "file"; - }; + default = { }; + example = lib.literalExpression '' + { + "/etc/hello" = { + source = ./files/hello; + permissions = "0700"; + operation = "file"; + }; - "/etc/xdg" = { - permissions = "0700"; - operation = "dir"; - }; + "/etc/xdg" = { + permissions = "0700"; + operation = "dir"; + }; - "/srv/data" = { - source = "/srv/data"; - operation = "symlink"; - }; + "/srv/data" = { + source = "/srv/data"; + operation = "symlink"; + }; - "/srv/logs".operation = "dir"; - } - ''; + "/srv/logs".operation = "dir"; + } + ''; + }; }; - }; # TODO: There has to be a better way to get this info without relying on # pkgs.closureInfo builder, right? @@ -177,29 +167,27 @@ let let sharedNixPathsClosureInfo = pkgs.closureInfo { inherit rootPaths; }; closurePaths = lib.readFile "${sharedNixPathsClosureInfo}/store-paths"; - in - lib.lists.filter (p: p != "") (lib.splitString "\n" closurePaths); -in -{ + in lib.lists.filter (p: p != "") (lib.splitString "\n" closurePaths); +in { options.wraparound.bubblewrap = bubblewrapModuleFactory { isGlobal = true; }; - options.wrappers = - let - bubblewrapModule = { config, lib, name, ... }: let - submoduleCfg = config.wraparound.bubblewrap; + options.wrappers = let + bubblewrapModule = { config, lib, name, ... }: + let submoduleCfg = config.wraparound.bubblewrap; in { - options.wraparound.bubblewrap = bubblewrapModuleFactory { isGlobal = false; }; + options.wraparound.bubblewrap = + bubblewrapModuleFactory { isGlobal = false; }; - config = lib.mkIf (config.wraparound.variant == "bubblewrap") (lib.mkMerge [ - { - wraparound.bubblewrap.binds = cfg.binds; - wraparound.bubblewrap.sharedNixPaths = cfg.sharedNixPaths; - wraparound.bubblewrap.filesystem = cfg.filesystem; - } + config = lib.mkIf (config.wraparound.variant == "bubblewrap") + (lib.mkMerge [ + { + wraparound.bubblewrap.binds = cfg.binds; + wraparound.bubblewrap.sharedNixPaths = cfg.sharedNixPaths; + wraparound.bubblewrap.filesystem = cfg.filesystem; + } - { - wraparound.bubblewrap.filesystem = - let + { + wraparound.bubblewrap.filesystem = let renameNixStorePaths = path: if lib.isDerivation path then path.pname else path; makeFilesystemMapping = operation: bind: @@ -209,57 +197,55 @@ in destination = builtins.toString bind; }; filesystemMappings = - lib.lists.map (makeFilesystemMapping "ro-bind-try") submoduleCfg.binds.ro - ++ lib.lists.map (makeFilesystemMapping "bind-try") submoduleCfg.binds.rw - ++ lib.lists.map (makeFilesystemMapping "dev-bind-try") submoduleCfg.binds.dev; - in - builtins.listToAttrs filesystemMappings; + lib.lists.map (makeFilesystemMapping "ro-bind-try") + submoduleCfg.binds.ro + ++ lib.lists.map (makeFilesystemMapping "bind-try") + submoduleCfg.binds.rw + ++ lib.lists.map (makeFilesystemMapping "dev-bind-try") + submoduleCfg.binds.dev; + in builtins.listToAttrs filesystemMappings; - wraparound.bubblewrap.extraArgs = - let + wraparound.bubblewrap.extraArgs = let makeFilesystemArgs = _: metadata: let src = metadata.source; dst = metadata.destination; hasPermissions = metadata.permissions != null; - isValidOperationWithPerms = lib.elem metadata.operation fileOperationsWithPerms; - in - # Take note of the ordering here such as `--perms` requiring + isValidOperationWithPerms = + lib.elem metadata.operation fileOperationsWithPerms; + # Take note of the ordering here such as `--perms` requiring # to be before the file operation flags. - lib.optionals (hasPermissions && isValidOperationWithPerms) [ "--perms ${metadata.permissions}" ] - ++ ( - if lib.elem metadata.operation [ "dir" "remount-ro" ] - then [ "--${metadata.operation} ${dst}" ] - else [ "--${metadata.operation} ${src} ${dst}" ] - ) + in lib.optionals (hasPermissions && isValidOperationWithPerms) + [ "--perms ${metadata.permissions}" ] + ++ (if lib.elem metadata.operation [ "dir" "remount-ro" ] then + [ "--${metadata.operation} ${dst}" ] + else + [ "--${metadata.operation} ${src} ${dst}" ]) ++ lib.optionals metadata.lock [ "--lock-file ${dst}" ]; - in - lib.lists.flatten (lib.mapAttrsToList makeFilesystemArgs submoduleCfg.filesystem); - } + in lib.lists.flatten + (lib.mapAttrsToList makeFilesystemArgs submoduleCfg.filesystem); + } - (lib.mkIf submoduleCfg.enableSharedNixStore { - wraparound.bubblewrap.binds.ro = [ builtins.storeDir ] ++ lib.optionals (builtins.storeDir != "/nix/store") [ "/nix/store" ]; - }) + (lib.mkIf submoduleCfg.enableSharedNixStore { + wraparound.bubblewrap.binds.ro = [ builtins.storeDir ] + ++ lib.optionals (builtins.storeDir != "/nix/store") + [ "/nix/store" ]; + }) - (lib.mkIf (submoduleCfg.sharedNixPaths != [ ]) { - wraparound.bubblewrap.extraArgs = - let - closurePaths = getClosurePaths submoduleCfg.sharedNixPaths; - in - builtins.map (p: "--ro-bind ${p} ${p}") closurePaths; - }) + (lib.mkIf (submoduleCfg.sharedNixPaths != [ ]) { + wraparound.bubblewrap.extraArgs = + let closurePaths = getClosurePaths submoduleCfg.sharedNixPaths; + in builtins.map (p: "--ro-bind ${p} ${p}") closurePaths; + }) - (lib.mkIf submoduleCfg.dbus.enable { - wraparound.bubblewrap.dbus.filter.bwrapArgs = - let - closurePaths = getClosurePaths submoduleCfg.sharedNixPaths; - in - builtins.map (p: "--ro-bind ${p} ${p}") closurePaths; - }) - ]); - }; - in - lib.mkOption { - type = with lib.types; attrsOf (submodule bubblewrapModule); + (lib.mkIf submoduleCfg.dbus.enable { + wraparound.bubblewrap.dbus.filter.bwrapArgs = + let closurePaths = getClosurePaths submoduleCfg.sharedNixPaths; + in builtins.map (p: "--ro-bind ${p} ${p}") closurePaths; + }) + ]); }; + in lib.mkOption { + type = with lib.types; attrsOf (submodule bubblewrapModule); + }; } diff --git a/modules/wrapper-manager/wraparound/bubblewrap/launcher.nix b/modules/wrapper-manager/wraparound/bubblewrap/launcher.nix index b8c7b009..7041d704 100644 --- a/modules/wrapper-manager/wraparound/bubblewrap/launcher.nix +++ b/modules/wrapper-manager/wraparound/bubblewrap/launcher.nix @@ -15,73 +15,87 @@ let Package containing the specialized Bubblewrap launcher used for this module. ''; - default = if isGlobal then pkgs.callPackage ./launcher/package.nix { } else cfg.package; + default = if isGlobal then + pkgs.callPackage ./launcher/package.nix { } + else + cfg.package; }; integrations = let - mkLauncherEnableOption = service: serviceName: lib.mkEnableOption "launcher integration for ${serviceName}" // { - default = if isGlobal then true else cfg.integrations.${service}.enable; - }; - in { - pipewire.enable = mkLauncherEnableOption "pipewire" "Pipewire"; - pulseaudio.enable = mkLauncherEnableOption "pulseaudio" "PulseAudio"; - wayland.enable = mkLauncherEnableOption "wayland" "Wayland desktop sessions"; - x11.enable = mkLauncherEnableOption "x11" "X11-based desktop sessions"; - }; + mkLauncherEnableOption = service: serviceName: + lib.mkEnableOption "launcher integration for ${serviceName}" // { + default = + if isGlobal then true else cfg.integrations.${service}.enable; + }; + in { + pipewire.enable = mkLauncherEnableOption "pipewire" "Pipewire"; + pulseaudio.enable = mkLauncherEnableOption "pulseaudio" "PulseAudio"; + wayland.enable = + mkLauncherEnableOption "wayland" "Wayland desktop sessions"; + x11.enable = mkLauncherEnableOption "x11" "X11-based desktop sessions"; + }; }; -in -{ - options.wraparound.bubblewrap.launcher = bubblewrapModuleFactory { isGlobal = true; }; +in { + options.wraparound.bubblewrap.launcher = + bubblewrapModuleFactory { isGlobal = true; }; - options.wrappers = - let - bubblewrapLauncherSubmodule = { config, lib, name, ... }: let + options.wrappers = let + bubblewrapLauncherSubmodule = { config, lib, name, ... }: + let submoduleCfg = config.wraparound.bubblewrap.launcher; envSuffix = word: "WRAPPER_MANAGER_BWRAP_LAUNCHER_${word}"; in { - options.wraparound.bubblewrap.launcher = bubblewrapModuleFactory { isGlobal = false; }; + options.wraparound.bubblewrap.launcher = + bubblewrapModuleFactory { isGlobal = false; }; - config = lib.mkIf (config.wraparound.variant == "bubblewrap") (lib.mkMerge [ - { - arg0 = lib.getExe' submoduleCfg.package "wrapper-manager-bubblewrap-launcher"; - prependArgs = lib.mkBefore - (config.wraparound.bubblewrap.extraArgs + config = lib.mkIf (config.wraparound.variant == "bubblewrap") + (lib.mkMerge [ + { + arg0 = lib.getExe' submoduleCfg.package + "wrapper-manager-bubblewrap-launcher"; + prependArgs = lib.mkBefore (config.wraparound.bubblewrap.extraArgs ++ [ "--" config.wraparound.subwrapper.arg0 ] ++ config.wraparound.subwrapper.extraArgs); - env = { - "${envSuffix "BWRAP"}".value = lib.getExe' config.wraparound.bubblewrap.package "bwrap"; - # We're just unsetting autoconfigure since we're configuring this - # through the module system anyways and would allow the user to - # have some more control over what can be enabled. - "${envSuffix "AUTOCONFIGURE"}".value = lib.mkDefault "0"; - }; - } + env = { + "${envSuffix "BWRAP"}".value = + lib.getExe' config.wraparound.bubblewrap.package "bwrap"; + # We're just unsetting autoconfigure since we're configuring this + # through the module system anyways and would allow the user to + # have some more control over what can be enabled. + "${envSuffix "AUTOCONFIGURE"}".value = lib.mkDefault "0"; + }; + } - (lib.mkIf config.wraparound.bubblewrap.dbus.enable { - env.${envSuffix "DBUS_PROXY"}.value = lib.getExe' config.wraparound.bubblewrap.dbus.filter.package "xdg-dbus-proxy"; - env.${envSuffix "DBUS_PROXY_ARGS"}.value = lib.concatStringsSep " " config.wraparound.bubblewrap.dbus.filter.extraArgs; - env.${envSuffix "DBUS_PROXY_BWRAP_ARGS"}.value = lib.concatStringsSep " " config.wraparound.bubblewrap.dbus.filter.bwrapArgs; - }) + (lib.mkIf config.wraparound.bubblewrap.dbus.enable { + env.${envSuffix "DBUS_PROXY"}.value = + lib.getExe' config.wraparound.bubblewrap.dbus.filter.package + "xdg-dbus-proxy"; + env.${envSuffix "DBUS_PROXY_ARGS"}.value = + lib.concatStringsSep " " + config.wraparound.bubblewrap.dbus.filter.extraArgs; + env.${envSuffix "DBUS_PROXY_BWRAP_ARGS"}.value = + lib.concatStringsSep " " + config.wraparound.bubblewrap.dbus.filter.bwrapArgs; + }) - (lib.mkIf submoduleCfg.integrations.pulseaudio.enable { - env.${envSuffix "PULSEAUDIO"}.value = "1"; - }) + (lib.mkIf submoduleCfg.integrations.pulseaudio.enable { + env.${envSuffix "PULSEAUDIO"}.value = "1"; + }) - (lib.mkIf submoduleCfg.integrations.pipewire.enable { - env.${envSuffix "PIPEWIRE"}.value = "1"; - }) + (lib.mkIf submoduleCfg.integrations.pipewire.enable { + env.${envSuffix "PIPEWIRE"}.value = "1"; + }) - (lib.mkIf submoduleCfg.integrations.x11.enable { - env.${envSuffix "X11"}.value = "1"; - }) + (lib.mkIf submoduleCfg.integrations.x11.enable { + env.${envSuffix "X11"}.value = "1"; + }) - (lib.mkIf submoduleCfg.integrations.wayland.enable { - env.${envSuffix "WAYLAND"}.value = "1"; - }) - ]); - }; - in - lib.mkOption { - type = with lib.types; attrsOf (submodule bubblewrapLauncherSubmodule); + (lib.mkIf submoduleCfg.integrations.wayland.enable { + env.${envSuffix "WAYLAND"}.value = "1"; + }) + ]); }; + in lib.mkOption { + type = with lib.types; attrsOf (submodule bubblewrapLauncherSubmodule); + }; } diff --git a/modules/wrapper-manager/wraparound/bubblewrap/launcher/app.sh b/modules/wrapper-manager/wraparound/bubblewrap/launcher/app.sh index fd40ab61..dac4e8ee 100644 --- a/modules/wrapper-manager/wraparound/bubblewrap/launcher/app.sh +++ b/modules/wrapper-manager/wraparound/bubblewrap/launcher/app.sh @@ -11,10 +11,11 @@ # * Using only the nixpkgs runtime shell and a few common dependencies found on # Unix-adjacent systems. # * No additional command-line options which means no flags and command-line -# parsing. This is essentially just a Bubblewrap wrapper. +# parsing. This is essentially just a Bubblewrap wrapper AND ONLY just a +# Bubblewrap wrapper. # * If we ever let the user configure things, it should be done with # environment variables with `WRAPPER_MANAGER_BWRAP_LAUNCHER` prefix. It's very -# long but who cares. +# long but who cares. It's made to be that tedious. ;D # * Ideally, there should be no options to clear the environment in this # launcher. Let the user do it themselves if they want. diff --git a/modules/wrapper-manager/wraparound/bubblewrap/launcher/package.nix b/modules/wrapper-manager/wraparound/bubblewrap/launcher/package.nix index b180e658..5e8ab533 100644 --- a/modules/wrapper-manager/wraparound/bubblewrap/launcher/package.nix +++ b/modules/wrapper-manager/wraparound/bubblewrap/launcher/package.nix @@ -1,9 +1,4 @@ -{ - stdenv, - lib, - meson, - ninja -}: +{ stdenv, lib, meson, ninja }: stdenv.mkDerivation (finalAttrs: { pname = "wrapper-manager-bubblewrap-launcher"; @@ -14,7 +9,8 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ meson ninja ]; meta = { - description = "wrapper-manager specialized launcher for Bubblewrap environments"; + description = + "wrapper-manager specialized launcher for Bubblewrap environments"; license = lib.licenses.mit; mainProgram = finalAttrs.pname; }; diff --git a/modules/wrapper-manager/wraparound/default.nix b/modules/wrapper-manager/wraparound/default.nix index 157f5495..e9dc9770 100644 --- a/modules/wrapper-manager/wraparound/default.nix +++ b/modules/wrapper-manager/wraparound/default.nix @@ -1,33 +1,28 @@ { lib, ... }: { - imports = [ - ./boxxy.nix - ./bubblewrap - ]; + imports = [ ./boxxy.nix ./bubblewrap ]; - options.wrappers = - let - wraparoundType = { name, lib, config, options, ... }: { - options.wraparound = { - variant = lib.mkOption { - type = with lib.types; nullOr (enum []); - description = '' - The wraparound variant to be applied to the wrapper. A value of - `null` will essentially disable it. - ''; - default = null; - example = "bubblewrap"; - }; + options.wrappers = let + wraparoundType = { name, lib, config, options, ... }: { + options.wraparound = { + variant = lib.mkOption { + type = with lib.types; nullOr (enum [ ]); + description = '' + The wraparound variant to be applied to the wrapper. A value of + `null` will essentially disable it. + ''; + default = null; + example = "bubblewrap"; + }; - subwrapper = { - arg0 = options.arg0; - extraArgs = options.prependArgs; - }; + subwrapper = { + arg0 = options.arg0; + extraArgs = options.prependArgs; }; }; - in - lib.mkOption { - type = with lib.types; attrsOf (submodule wraparoundType); }; + in lib.mkOption { + type = with lib.types; attrsOf (submodule wraparoundType); + }; } diff --git a/overlays/blender-foodogsquared/default.nix b/overlays/blender-foodogsquared/default.nix index 69278629..3669f54b 100644 --- a/overlays/blender-foodogsquared/default.nix +++ b/overlays/blender-foodogsquared/default.nix @@ -1,10 +1,6 @@ final: prev: { - blender-foodogsquared = prev.blender.withPackages (p: - with p; [ - pandas - scipy - pillow - ]); + blender-foodogsquared = + prev.blender.withPackages (p: with p; [ pandas scipy pillow ]); } diff --git a/overlays/ffmpeg-foodogsquared/default.nix b/overlays/ffmpeg-foodogsquared/default.nix index 571a950f..7d00e861 100644 --- a/overlays/ffmpeg-foodogsquared/default.nix +++ b/overlays/ffmpeg-foodogsquared/default.nix @@ -16,32 +16,25 @@ let hash = "sha256-Qy5sZgNF/0uNCosj2NZEvyssXU9ln6ZsDjnt/orpt1k="; name = "ffmpeg-shadertoy"; }; -in -{ - ffmpeg-foodogsquared = prev.ffmpeg-full.overrideAttrs (finalAttrs: prevAttrs: { - pname = "ffmpeg-foodogsquared"; - srcs = [ - prevAttrs.src - ffmpegGLTransitions - ffmpegShadertoy - ]; - buildInputs = prevAttrs.buildInputs ++ (with prev; [ - libGLU - glew - ]); - sourceRoot = "."; - patches = prevAttrs.patches ++ [ - ./add-custom-filters.patch - ./update-ffmpeg-opengltransition.patch - ]; - postUnpack = '' - cd ./${ffmpegGLTransitions.name} - cd ../ +in { + ffmpeg-foodogsquared = prev.ffmpeg-full.overrideAttrs + (finalAttrs: prevAttrs: { + pname = "ffmpeg-foodogsquared"; + srcs = [ prevAttrs.src ffmpegGLTransitions ffmpegShadertoy ]; + buildInputs = prevAttrs.buildInputs ++ (with prev; [ libGLU glew ]); + sourceRoot = "."; + patches = prevAttrs.patches ++ [ + ./add-custom-filters.patch + ./update-ffmpeg-opengltransition.patch + ]; + postUnpack = '' + cd ./${ffmpegGLTransitions.name} + cd ../ - cp --no-preserve=mode ./${ffmpegGLTransitions.name}/vf_gltransition.c ./ffmpeg/libavfilter - cp --no-preserve=mode ./${ffmpegShadertoy.name}/vf_shadertoy.c ./ffmpeg/libavfilter + cp --no-preserve=mode ./${ffmpegGLTransitions.name}/vf_gltransition.c ./ffmpeg/libavfilter + cp --no-preserve=mode ./${ffmpegShadertoy.name}/vf_shadertoy.c ./ffmpeg/libavfilter - cd ffmpeg - ''; - }); + cd ffmpeg + ''; + }); } diff --git a/overlays/firefox-foodogsquared/default.nix b/overlays/firefox-foodogsquared/default.nix index 813d6e0b..14208011 100644 --- a/overlays/firefox-foodogsquared/default.nix +++ b/overlays/firefox-foodogsquared/default.nix @@ -2,71 +2,76 @@ final: prev: { - firefox-foodogsquared = with prev; wrapFirefox firefox-unwrapped { - nativeMessagingHosts = [ - ff2mpv - bukubrow - tridactyl-native - ]; + firefox-foodogsquared = with prev; + wrapFirefox firefox-unwrapped { + nativeMessagingHosts = [ ff2mpv bukubrow tridactyl-native ]; - extraPolicies = { - AppAutoUpdate = false; + extraPolicies = { + AppAutoUpdate = false; - Containers.Default = - let - mkContainer = name: color: icon: { - inherit name color icon; - }; - in - [ - (mkContainer "Personal" "blue" "fingerprint") - (mkContainer "Self-hosted" "pink" "fingerprint") - (mkContainer "Work" "red" "briefcase") - (mkContainer "Banking" "green" "dollar") - (mkContainer "Shopping" "pink" "cart") - (mkContainer "Gaming" "turquoise" "chill") - ]; + Containers.Default = + let mkContainer = name: color: icon: { inherit name color icon; }; + in [ + (mkContainer "Personal" "blue" "fingerprint") + (mkContainer "Self-hosted" "pink" "fingerprint") + (mkContainer "Work" "red" "briefcase") + (mkContainer "Banking" "green" "dollar") + (mkContainer "Shopping" "pink" "cart") + (mkContainer "Gaming" "turquoise" "chill") + ]; - DisableAppUpdate = true; - DisableMasterPasswordCreation = true; - DisablePocket = true; - DisableSetDesktopBackground = true; - DontCheckDefaultBrowser = true; - EnableTrackingProtection = true; + DisableAppUpdate = true; + DisableMasterPasswordCreation = true; + DisablePocket = true; + DisableSetDesktopBackground = true; + DontCheckDefaultBrowser = true; + EnableTrackingProtection = true; - ExtensionSettings = - let - mozillaAddon = id: "https://addons.mozilla.org/firefox/downloads/latest/${id}/latest.xpi"; + ExtensionSettings = let + mozillaAddon = id: + "https://addons.mozilla.org/firefox/downloads/latest/${id}/latest.xpi"; # This option assumes the default installation mode is `normal_installed`. extensions = { "@contain-facebook".install_url = mozillaAddon "facebook-container"; "@contain-google".install_url = mozillaAddon "google-container"; - "@testpilot-containers".install_url = mozillaAddon "multi-account-containers"; - "{157eb9f0-9814-4fcc-b0b7-586b3093c641}".install_url = mozillaAddon "updateswh"; - "{15bdb1ce-fa9d-4a00-b859-66c214263ac0}".install_url = mozillaAddon "get-rss-feed-url"; + "@testpilot-containers".install_url = + mozillaAddon "multi-account-containers"; + "{157eb9f0-9814-4fcc-b0b7-586b3093c641}".install_url = + mozillaAddon "updateswh"; + "{15bdb1ce-fa9d-4a00-b859-66c214263ac0}".install_url = + mozillaAddon "get-rss-feed-url"; "{446900e4-71c2-419f-a6a7-df9c091e268b}" = { install_url = mozillaAddon "bitwarden-password-manager"; installation_mode = "force_installed"; default_area = "navbar"; }; - "{dedb3663-6f13-4c6c-bf0f-5bd111cb2c79}".install_url = mozillaAddon "zhongwen"; - "{ef87d84c-2127-493f-b952-5b4e744245bc}".install_url = mozillaAddon "aw-watcher-web"; + "{dedb3663-6f13-4c6c-bf0f-5bd111cb2c79}".install_url = + mozillaAddon "zhongwen"; + "{ef87d84c-2127-493f-b952-5b4e744245bc}".install_url = + mozillaAddon "aw-watcher-web"; "ff2mpv@yossarian.net" = { install_url = mozillaAddon "ff2mpv"; default_area = "navbar"; }; - "FirefoxColor@mozilla.com".install_url = mozillaAddon "firefox-color"; - "firefox-translations-addon@mozilla.org".install_url = mozillaAddon "firefox-translations"; - "jid1-MnnxcxisBPnSXQ@jetpack".install_url = mozillaAddon "privacy-badger17"; - "regrets-reporter@mozillafoundation.org".install_url = mozillaAddon "regretsreporter"; - "tridactyl.vim@cmcaine.co.uk".install_url = mozillaAddon "tridactyl-vim"; - "uBlock0@raymondhill.net".install_url = mozillaAddon "ublock-origin"; + "FirefoxColor@mozilla.com".install_url = + mozillaAddon "firefox-color"; + "firefox-translations-addon@mozilla.org".install_url = + mozillaAddon "firefox-translations"; + "jid1-MnnxcxisBPnSXQ@jetpack".install_url = + mozillaAddon "privacy-badger17"; + "regrets-reporter@mozillafoundation.org".install_url = + mozillaAddon "regretsreporter"; + "tridactyl.vim@cmcaine.co.uk".install_url = + mozillaAddon "tridactyl-vim"; + "uBlock0@raymondhill.net".install_url = + mozillaAddon "ublock-origin"; "wayback_machine@mozilla.org" = { install_url = mozillaAddon "wayback-machine_new"; default_area = "navbar"; }; - "zotero@chnm.gmu.edu".install_url = "https://www.zotero.org/download/connector/dl?browser=firefox"; + "zotero@chnm.gmu.edu".install_url = + "https://www.zotero.org/download/connector/dl?browser=firefox"; "info@oahelper.org" = { install_url = mozillaAddon "open-access-helper"; default_area = "navbar"; @@ -74,61 +79,63 @@ final: prev: }; applyInstallationMode = name: value: - lib.nameValuePair name (value // - (lib.optionalAttrs - (! (lib.hasAttrByPath [ "installation_mode" ] value)) - { installation_mode = "normal_installed"; })); - in - lib.mapAttrs' applyInstallationMode extensions; + lib.nameValuePair name (value // (lib.optionalAttrs + (!(lib.hasAttrByPath [ "installation_mode" ] value)) { + installation_mode = "normal_installed"; + })); + in lib.mapAttrs' applyInstallationMode extensions; - FirefoxHome = { - Highlights = false; - Pocket = false; - Snippets = false; - SponsporedPocket = false; - SponsporedTopSites = false; - }; + FirefoxHome = { + Highlights = false; + Pocket = false; + Snippets = false; + SponsporedPocket = false; + SponsporedTopSites = false; + }; - NoDefaultBookmarks = true; - OfferToSaveLoginsDefault = false; - PasswordManagerEnabled = false; - SanitizeOnShutdown = { - FormData = true; + NoDefaultBookmarks = true; + OfferToSaveLoginsDefault = false; + PasswordManagerEnabled = false; + SanitizeOnShutdown = { FormData = true; }; + UseSystemPrintDialog = true; }; - UseSystemPrintDialog = true; }; - }; # A custom Firefox package with specific configuration intended for guest # environments. - firefox-foodogsquared-guest = with prev; wrapFirefox firefox-unwrapped { - nativeMessagingHosts = [ - tridactyl-native - ]; + firefox-foodogsquared-guest = with prev; + wrapFirefox firefox-unwrapped { + nativeMessagingHosts = [ tridactyl-native ]; - extraPolicies = { - AppAutoUpdate = false; - DisableAppUpdate = true; - DisableMasterPasswordCreation = true; - DisablePocket = true; - DisableSetDesktopBackground = true; - DontCheckDefaultBrowser = true; - EnableTrackingProtection = true; + extraPolicies = { + AppAutoUpdate = false; + DisableAppUpdate = true; + DisableMasterPasswordCreation = true; + DisablePocket = true; + DisableSetDesktopBackground = true; + DontCheckDefaultBrowser = true; + EnableTrackingProtection = true; - ExtensionSettings = - let - mozillaAddon = id: "https://addons.mozilla.org/firefox/downloads/latest/${id}/latest.xpi"; + ExtensionSettings = let + mozillaAddon = id: + "https://addons.mozilla.org/firefox/downloads/latest/${id}/latest.xpi"; # This option assumes the default installation mode is `normal_installed`. extensions = { "@contain-facebook".install_url = mozillaAddon "facebook-container"; "@contain-google".install_url = mozillaAddon "google-container"; - "@testpilot-containers".install_url = mozillaAddon "multi-account-containers"; - "FirefoxColor@mozilla.com".install_url = mozillaAddon "firefox-color"; - "firefox-translations-addon@mozilla.org".install_url = mozillaAddon "firefox-translations"; - "jid1-MnnxcxisBPnSXQ@jetpack".install_url = mozillaAddon "privacy-badger17"; - "tridactyl.vim@cmcaine.co.uk".install_url = mozillaAddon "tridactyl-vim"; - "uBlock0@raymondhill.net".install_url = mozillaAddon "ublock-origin"; + "@testpilot-containers".install_url = + mozillaAddon "multi-account-containers"; + "FirefoxColor@mozilla.com".install_url = + mozillaAddon "firefox-color"; + "firefox-translations-addon@mozilla.org".install_url = + mozillaAddon "firefox-translations"; + "jid1-MnnxcxisBPnSXQ@jetpack".install_url = + mozillaAddon "privacy-badger17"; + "tridactyl.vim@cmcaine.co.uk".install_url = + mozillaAddon "tridactyl-vim"; + "uBlock0@raymondhill.net".install_url = + mozillaAddon "ublock-origin"; "wayback_machine@mozilla.org" = { install_url = mozillaAddon "wayback-machine_new"; default_area = "navbar"; @@ -136,28 +143,25 @@ final: prev: }; applyInstallationMode = name: value: - lib.nameValuePair name (value // - (lib.optionalAttrs - (! (lib.hasAttrByPath [ "installation_mode" ] value)) - { installation_mode = "normal_installed"; })); - in - lib.mapAttrs' applyInstallationMode extensions; + lib.nameValuePair name (value // (lib.optionalAttrs + (!(lib.hasAttrByPath [ "installation_mode" ] value)) { + installation_mode = "normal_installed"; + })); + in lib.mapAttrs' applyInstallationMode extensions; - FirefoxHome = { - Highlights = false; - Pocket = false; - Snippets = false; - SponsporedPocket = false; - SponsporedTopSites = false; - }; + FirefoxHome = { + Highlights = false; + Pocket = false; + Snippets = false; + SponsporedPocket = false; + SponsporedTopSites = false; + }; - NoDefaultBookmarks = true; - OfferToSaveLoginsDefault = false; - PasswordManagerEnabled = false; - SanitizeOnShutdown = { - FormData = true; + NoDefaultBookmarks = true; + OfferToSaveLoginsDefault = false; + PasswordManagerEnabled = false; + SanitizeOnShutdown = { FormData = true; }; + UseSystemPrintDialog = true; }; - UseSystemPrintDialog = true; }; - }; } diff --git a/overlays/rotp-foodogsquared/default.nix b/overlays/rotp-foodogsquared/default.nix index dc2a49b3..4c7b25de 100644 --- a/overlays/rotp-foodogsquared/default.nix +++ b/overlays/rotp-foodogsquared/default.nix @@ -9,16 +9,16 @@ let icon = "com.remnantsoftheprecursors.ROTP"; categories = [ "Application" "Game" ]; }; -in -{ +in { rotp-foodogsquared = prev.rotp.overrideAttrs (finalAttrs: prevAttrs: { - desktopItems = (prevAttrs.desktopItems or []) ++ [ rotpDesktop ]; - nativeBuildInputs = prevAttrs.nativeBuildInputs or [] ++ [ - prev.copyDesktopItems - ]; + desktopItems = (prevAttrs.desktopItems or [ ]) ++ [ rotpDesktop ]; + nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] + ++ [ prev.copyDesktopItems ]; postInstall = '' ${prevAttrs.postInstall or ""} - install -Dm0644 ${./com.remnantsoftheprecursors.ROTP.png} ${placeholder "out"}/share/icons/hicolor/128x128/apps/com.remnantsoftheprecursors.ROTP.png + install -Dm0644 ${./com.remnantsoftheprecursors.ROTP.png} ${ + placeholder "out" + }/share/icons/hicolor/128x128/apps/com.remnantsoftheprecursors.ROTP.png ''; }); } diff --git a/overlays/thunderbird-foodogsquared/default.nix b/overlays/thunderbird-foodogsquared/default.nix index 640473d5..369285e7 100644 --- a/overlays/thunderbird-foodogsquared/default.nix +++ b/overlays/thunderbird-foodogsquared/default.nix @@ -3,35 +3,37 @@ final: prev: { - thunderbird-foodogsquared = with prev; wrapThunderbird thunderbird-unwrapped { - extraPolicies = { - AppsAutoUpdate = false; - DisableAppUpdate = false; + thunderbird-foodogsquared = with prev; + wrapThunderbird thunderbird-unwrapped { + extraPolicies = { + AppsAutoUpdate = false; + DisableAppUpdate = false; - ExtensionSettings = let - thunderbirdAddon = name: - "https://addons.thunderbird.net/thunderbird/downloads/latest/${name}/latest.xpi"; + ExtensionSettings = let + thunderbirdAddon = name: + "https://addons.thunderbird.net/thunderbird/downloads/latest/${name}/latest.xpi"; - extensions = { - "uBlock0@raymondhill.net" = { - installation_mode = "force_installed"; - installation_url = thunderbirdAddon "ublock-origin"; + extensions = { + "uBlock0@raymondhill.net" = { + installation_mode = "force_installed"; + installation_url = thunderbirdAddon "ublock-origin"; + }; + + "{e6696d02-466a-11e3-a162-04e36188709b}".installation_url = + thunderbirdAddon "eds-calendar-integration"; + "quickfolders@curious.be".installation_url = + thunderbirdAddon "quickfolders-tabbed-folders"; }; - "{e6696d02-466a-11e3-a162-04e36188709b}".installation_url = thunderbirdAddon "eds-calendar-integration"; - "quickfolders@curious.be".installation_url = thunderbirdAddon "quickfolders-tabbed-folders"; - }; + applyInstallationMode = name: value: + lib.nameValuePair name (value // (lib.optionalAttrs + (!(lib.hasAttrByPath [ "installation_mode" ] value)) { + installation_mode = "normal_installed"; + })); + in lib.mapAttrs' applyInstallationMode extensions; - applyInstallationMode = name: value: - lib.nameValuePair name (value // - (lib.optionalAttrs - (! (lib.hasAttrByPath [ "installation_mode" ] value)) - { installation_mode = "normal_installed"; })); - in - lib.mapAttrs' applyInstallationMode extensions; - - OfferToSaveLoginsDefault = false; - PasswordManagerEnabled = false; + OfferToSaveLoginsDefault = false; + PasswordManagerEnabled = false; + }; }; - }; } diff --git a/shell.nix b/shell.nix index 7e897bd7..2902c8fd 100644 --- a/shell.nix +++ b/shell.nix @@ -1,41 +1,40 @@ { pkgs ? import { }, extraPackages ? [ ] }: -let - run-workflow-in-vm = pkgs.callPackage ./apps/run-workflow-with-vm { }; -in -pkgs.mkShell { - packages = with pkgs; [ - # My internal applications. - run-workflow-in-vm +let run-workflow-in-vm = pkgs.callPackage ./apps/run-workflow-with-vm { }; +in pkgs.mkShell { + packages = with pkgs; + [ + # My internal applications. + run-workflow-in-vm - age - asciidoctor - disko - deploy-rs - hcloud - npins - nixos-anywhere - home-manager - git - sops - nix-update + age + asciidoctor + disko + deploy-rs + hcloud + npins + nixos-anywhere + home-manager + git + sops + nix-update - bind - opentofu + bind + opentofu - jq - wl-clipboard + jq + wl-clipboard - # Language servers for various parts of the config that uses a language. - lua-language-server - pyright - nil - terraform-ls + # Language servers for various parts of the config that uses a language. + lua-language-server + pyright + nil + terraform-ls - # Formatters... - treefmt # The universal formatter (if you configured it). - stylua # ...for Lua. - black # ...for Python. - nixfmt # ...for Nix. - ] ++ extraPackages; + # Formatters... + treefmt # The universal formatter (if you configured it). + stylua # ...for Lua. + black # ...for Python. + nixfmt # ...for Nix. + ] ++ extraPackages; } diff --git a/shells/cloud.nix b/shells/cloud.nix index 63608a54..94b88d9b 100644 --- a/shells/cloud.nix +++ b/shells/cloud.nix @@ -8,27 +8,26 @@ (buildFHSUserEnv { name = "cloud-admin-env"; - targetPkgs = pkgs: (with pkgs; [ - awscli2 # For Amazon Web Services. - azure-cli # For Microsoft Azure. + targetPkgs = pkgs: + (with pkgs; [ + awscli2 # For Amazon Web Services. + azure-cli # For Microsoft Azure. - # For Google Cloud Platform. - (google-cloud-sdk.withExtraComponents - (with google-cloud-sdk.components; [ + # For Google Cloud Platform. + (google-cloud-sdk.withExtraComponents (with google-cloud-sdk.components; [ gke-gcloud-auth-plugin gcloud-man-pages cloud-run-proxy - ]) - ) + ])) - kubectl # For managing Kubernetes cluster if it is on one. - hcloud # For Hetzner Cloud. - linode-cli # For Linode. - vultr-cli # For Vultr. + kubectl # For managing Kubernetes cluster if it is on one. + hcloud # For Hetzner Cloud. + linode-cli # For Linode. + vultr-cli # For Vultr. - # It's here since Google Cloud SDK needs it. - python3 + # It's here since Google Cloud SDK needs it. + python3 - opentofu # The declarative thingy for cloud. - ]); + opentofu # The declarative thingy for cloud. + ]); }).env diff --git a/shells/creatives.nix b/shells/creatives.nix index 1dd41517..312da8d2 100644 --- a/shells/creatives.nix +++ b/shells/creatives.nix @@ -1,12 +1,6 @@ # Trying to be creative with coding while endlessly referring to some tutorials # on the internet. -{ mkShell -, supercollider -, bonzomatic -, processing -, puredata -, shaderc -}: +{ mkShell, supercollider, bonzomatic, processing, puredata, shaderc }: mkShell { packages = [ diff --git a/shells/default.nix b/shells/default.nix index 1e5dc324..d48cc918 100644 --- a/shells/default.nix +++ b/shells/default.nix @@ -12,8 +12,15 @@ with pkgs; { go = callPackage ./go.nix { }; guile = callPackage ./guile.nix { }; guile2 = callPackage ./guile.nix { guile = guile_2_2; }; - gtk3 = callPackage ./gtk.nix { gtk = gtk3; libportal-gtk = libportal-gtk3; }; - gtk4 = callPackage ./gtk.nix { gtk = gtk4; wrapGAppsHook = wrapGAppsHook4; libportal-gtk = libportal-gtk4; }; + gtk3 = callPackage ./gtk.nix { + gtk = gtk3; + libportal-gtk = libportal-gtk3; + }; + gtk4 = callPackage ./gtk.nix { + gtk = gtk4; + wrapGAppsHook = wrapGAppsHook4; + libportal-gtk = libportal-gtk4; + }; hugo = callPackage ./hugo.nix { }; latex = callPackage ./latex.nix { }; lua_5_2 = callPackage ./lua.nix { lua = lua52Packages.lua; }; diff --git a/shells/flatpak.nix b/shells/flatpak.nix index 6d0417ae..c931e6bc 100644 --- a/shells/flatpak.nix +++ b/shells/flatpak.nix @@ -1,15 +1,7 @@ # My custom shell for developing Flatpak manifests. # This is not suitable outside of NixOS, unfortunately. -{ mkShell -, lib -, diffoscope -, desktop-file-utils -, flatpak-builder -, editorconfig-checker -, editorconfig-core-c -, git -, dasel -}: +{ mkShell, lib, diffoscope, desktop-file-utils, flatpak-builder +, editorconfig-checker, editorconfig-core-c, git, dasel }: mkShell { packages = [ diff --git a/shells/gnome.nix b/shells/gnome.nix index 3e3702b1..d1491760 100644 --- a/shells/gnome.nix +++ b/shells/gnome.nix @@ -3,35 +3,16 @@ # projects. # # These include toolkits for C, Rust, and GNOME JavaScript. -{ mkShell -, cmake -, meson -, ninja -, gtk4 -, libadwaita -, gjs -, pkg-config +{ mkShell, cmake, meson, ninja, gtk4, libadwaita, gjs, pkg-config -, blueprint-compiler -, desktop-file-utils -, librsvg -, gdk-pixbuf -, gst_all_1 -, gettext -, glib -, appstream-glib -, json-glib -, gobject-introspection -, glib-networking -, glib-testing -, libsoup_3 +, blueprint-compiler, desktop-file-utils, librsvg, gdk-pixbuf, gst_all_1 +, gettext, glib, appstream-glib, json-glib, gobject-introspection +, glib-networking, glib-testing, libsoup_3 , nodePackages - # Rust -, cargo -, rustc -}: +# Rust +, cargo, rustc }: mkShell { packages = [ diff --git a/shells/gnu.nix b/shells/gnu.nix index c2da1c2f..e4c62c2c 100644 --- a/shells/gnu.nix +++ b/shells/gnu.nix @@ -4,19 +4,8 @@ # It's a good thing they have documented the full details in one of their # manuals at # https://www.gnu.org/software/automake/manual/html_node/GNU-Build-System.html -{ mkShell -, lib -, autoconf -, autoconf-archive -, automake -, gnumake -, gcc -, gettext -, coreutils -, pkg-config -, help2man -, texinfo -}: +{ mkShell, lib, autoconf, autoconf-archive, automake, gnumake, gcc, gettext +, coreutils, pkg-config, help2man, texinfo }: mkShell { packages = [ @@ -32,9 +21,5 @@ mkShell { pkg-config ]; - inputsFrom = [ - gcc - coreutils - gnumake - ]; + inputsFrom = [ gcc coreutils gnumake ]; } diff --git a/shells/go.nix b/shells/go.nix index 391012b3..5499ddcf 100644 --- a/shells/go.nix +++ b/shells/go.nix @@ -1,19 +1,8 @@ -{ mkShell -, go -, gofumpt -, gopls -, callPackage -}: +{ mkShell, go, gofumpt, gopls, callPackage }: -let - nodejsDevshell = callPackage ./nodejs.nix { }; -in -mkShell { - packages = [ - go - gofumpt - gopls - ]; +let nodejsDevshell = callPackage ./nodejs.nix { }; +in mkShell { + packages = [ go gofumpt gopls ]; inputsFrom = [ go nodejsDevshell ]; } diff --git a/shells/gtk.nix b/shells/gtk.nix index 2d90a98e..5897d538 100644 --- a/shells/gtk.nix +++ b/shells/gtk.nix @@ -1,18 +1,6 @@ -{ mkShell -, lib -, wrapGAppsHook -, desktop-file-utils -, glib -, appstream-glib -, blueprint-compiler -, libadwaita -, libportal -, libportal-gtk -, gtk -, meson -, ninja -, pkg-config -}: +{ mkShell, lib, wrapGAppsHook, desktop-file-utils, glib, appstream-glib +, blueprint-compiler, libadwaita, libportal, libportal-gtk, gtk, meson, ninja +, pkg-config }: mkShell { packages = [ diff --git a/shells/guile.nix b/shells/guile.nix index 25ff5504..4d5052cc 100644 --- a/shells/guile.nix +++ b/shells/guile.nix @@ -1,25 +1,9 @@ -{ mkShell -, lib -, gcc -, gettext -, pkg-config -, texinfo -, guile -, guile-hall -}: +{ mkShell, lib, gcc, gettext, pkg-config, texinfo, guile, guile-hall }: -let - guileVersion = lib.versions.majorMinor guile.version; -in -mkShell { +let guileVersion = lib.versions.majorMinor guile.version; +in mkShell { inherit guileVersion; - packages = [ - gettext - guile - guile-hall - pkg-config - texinfo - ]; + packages = [ gettext guile guile-hall pkg-config texinfo ]; inputsFrom = [ gcc guile ]; } diff --git a/shells/hugo.nix b/shells/hugo.nix index 3ec7c86e..8bbd4a60 100644 --- a/shells/hugo.nix +++ b/shells/hugo.nix @@ -1,20 +1,11 @@ # My usual toolchain for developing Hugo projects. -{ mkShell -, callPackage -, hugo -, asciidoctor -, pandoc -, git -, go -, nodejs_latest -, imagemagick -}: +{ mkShell, callPackage, hugo, asciidoctor, pandoc, git, go, nodejs_latest +, imagemagick }: let nodejsDevshell = callPackage ./nodejs.nix { }; goDevshell = callPackage ./go.nix { }; -in -mkShell { +in mkShell { packages = [ asciidoctor # Some sites use this. pandoc # Also these. @@ -25,8 +16,5 @@ mkShell { imagemagick # Everyman's image processing framework. ]; - inputsFrom = [ - nodejsDevshell - goDevshell - ]; + inputsFrom = [ nodejsDevshell goDevshell ]; } diff --git a/shells/latex.nix b/shells/latex.nix index 3d70e8ec..c0bab3db 100644 --- a/shells/latex.nix +++ b/shells/latex.nix @@ -1,8 +1,5 @@ # Ripperootskees for the disk space. -{ mkShell -, texlive -, texlab -}: +{ mkShell, texlive, texlab }: mkShell { packages = [ diff --git a/shells/lua.nix b/shells/lua.nix index dca92a7e..ffb78cd5 100644 --- a/shells/lua.nix +++ b/shells/lua.nix @@ -1,20 +1,9 @@ # It is much more recommended to create a project-specific development # environment for Lua projects instead. -{ mkShell -, gcc -, lua -, luarocks -, stylua -, sumneko-lua-language-server -}: +{ mkShell, gcc, lua, luarocks, stylua, sumneko-lua-language-server }: mkShell { - packages = [ - lua - luarocks - stylua - sumneko-lua-language-server - ]; + packages = [ lua luarocks stylua sumneko-lua-language-server ]; inputsFrom = [ lua gcc ]; } diff --git a/shells/nix.nix b/shells/nix.nix index dae8a008..6757dd22 100644 --- a/shells/nix.nix +++ b/shells/nix.nix @@ -1,16 +1,7 @@ # For usual Nix projects such as overlays, package repositories, and whatnot. # Also, it's fun to have a file named `nix.nix`. -{ mkShell -, lib -, deadnix -, jq -, nil -, nix-tree -, nixfmt -, nixpkgs-hammering -, nurl -, rnix-hashes -}: +{ mkShell, lib, deadnix, jq, nil, nix-tree, nixfmt, nixpkgs-hammering, nurl +, rnix-hashes }: mkShell { packages = [ diff --git a/shells/nodejs.nix b/shells/nodejs.nix index 1788d3b7..49f50d7d 100644 --- a/shells/nodejs.nix +++ b/shells/nodejs.nix @@ -1,11 +1,4 @@ # Bundling everything for my fullstack (in JS) webdev needs. { mkShell, nodejs, bun, esbuild, pnpm }: -mkShell { - packages = [ - nodejs - bun - esbuild - pnpm - ]; -} +mkShell { packages = [ nodejs bun esbuild pnpm ]; } diff --git a/shells/rust.nix b/shells/rust.nix index 4332ca71..d6a3e927 100644 --- a/shells/rust.nix +++ b/shells/rust.nix @@ -1,17 +1,7 @@ # This is just for a quick development setup. Otherwise, I recommend # to use the `rust` template from `nixpkgs` or whatever you prefer. -{ mkShell -, openssl -, pkg-config -, cargo -, rustc -, rustfmt -, rust-analyzer -, meson -, ninja -, rustPackages -, rustPlatform -}: +{ mkShell, openssl, pkg-config, cargo, rustc, rustfmt, rust-analyzer, meson +, ninja, rustPackages, rustPlatform }: mkShell { buildInputs = [ diff --git a/shells/tic-80.nix b/shells/tic-80.nix index 1f61980b..95f9ec12 100644 --- a/shells/tic-80.nix +++ b/shells/tic-80.nix @@ -3,10 +3,4 @@ # development with plain text cartridges. { mkShell, tic-80, imagemagick }: -mkShell { - packages = [ - tic-80 - tic-80.dev - imagemagick - ]; -} +mkShell { packages = [ tic-80 tic-80.dev imagemagick ]; } diff --git a/templates/basic-nix-cpp-app/default.nix b/templates/basic-nix-cpp-app/default.nix index 57f6cd28..e4958edc 100644 --- a/templates/basic-nix-cpp-app/default.nix +++ b/templates/basic-nix-cpp-app/default.nix @@ -1,13 +1,4 @@ -{ stdenv -, lib -, cmake -, meson -, ninja -, pkg-config -, boost -, nix -, semver-cpp -}: +{ stdenv, lib, cmake, meson, ninja, pkg-config, boost, nix, semver-cpp }: stdenv.mkDerivation { pname = "app"; @@ -15,18 +6,9 @@ stdenv.mkDerivation { src = ./.; - nativeBuildInputs = [ - meson - ninja - pkg-config - ]; + nativeBuildInputs = [ meson ninja pkg-config ]; - buildInputs = [ - cmake - boost - nix - semver-cpp - ]; + buildInputs = [ cmake boost nix semver-cpp ]; meta = with lib; { description = "Basic Nix CLI"; diff --git a/templates/basic-nix-cpp-app/shell.nix b/templates/basic-nix-cpp-app/shell.nix index 0bd9b241..9b845273 100644 --- a/templates/basic-nix-cpp-app/shell.nix +++ b/templates/basic-nix-cpp-app/shell.nix @@ -1,13 +1,8 @@ { pkgs ? import { } }: -let - app = pkgs.callPackage ./. { }; -in -pkgs.mkShell { +let app = pkgs.callPackage ./. { }; +in pkgs.mkShell { inputsFrom = [ app ]; - packages = with pkgs; [ - git - clang-tools - ]; + packages = with pkgs; [ git clang-tools ]; } diff --git a/templates/basic-nix-module-flake/flake.nix b/templates/basic-nix-module-flake/flake.nix index 729110a6..dae83041 100644 --- a/templates/basic-nix-module-flake/flake.nix +++ b/templates/basic-nix-module-flake/flake.nix @@ -8,13 +8,8 @@ outputs = inputs@{ self, nixpkgs, ... }: inputs.flake-parts.lib.mkFlake { inherit inputs; } { - systems = [ - "x86_64-linux" - "aarch64-linux" - ]; + systems = [ "x86_64-linux" "aarch64-linux" ]; - imports = [ - ./nix/flake - ]; + imports = [ ./nix/flake ]; }; } diff --git a/templates/basic-nix-module-flake/nix/flake/default.nix b/templates/basic-nix-module-flake/nix/flake/default.nix index 365ce6eb..00a1d0a5 100644 --- a/templates/basic-nix-module-flake/nix/flake/default.nix +++ b/templates/basic-nix-module-flake/nix/flake/default.nix @@ -1,7 +1,5 @@ { lib, inputs, ... }: { - flake = { - nixosModules.default = ../modules; - }; + flake = { nixosModules.default = ../modules; }; perSystem = { lib, pkgs, system, ... }: { formatter = pkgs.treefmt; @@ -10,23 +8,19 @@ # Just make sure it actually compiles with a very minimal NixOS # configuration. - checks.nixos-module-test = - let - nixosSystem = args: - import "${inputs.nixpkgs}/nixos/lib/eval-config.nix" args; - in - nixosSystem { - modules = [ - ({ modulesPath, ... }: { - imports = [ - "${modulesPath}/profiles/minimal.nix" - ]; + checks.nixos-module-test = let + nixosSystem = args: + import "${inputs.nixpkgs}/nixos/lib/eval-config.nix" args; + in nixosSystem { + modules = [ + ({ modulesPath, ... }: { + imports = [ "${modulesPath}/profiles/minimal.nix" ]; - nixpkgs.hostPlatform = system; - boot.loader.grub.enable = false; - fileSystems."/".device = "nodev"; - }) - ]; - }; + nixpkgs.hostPlatform = system; + boot.loader.grub.enable = false; + fileSystems."/".device = "nodev"; + }) + ]; + }; }; } diff --git a/templates/basic-nix-module-flake/nix/modules/default.nix b/templates/basic-nix-module-flake/nix/modules/default.nix index 83b02d13..80f9bc0b 100644 --- a/templates/basic-nix-module-flake/nix/modules/default.nix +++ b/templates/basic-nix-module-flake/nix/modules/default.nix @@ -4,8 +4,7 @@ let cfg = config.programs.foo; settingsFormat = pkgs.format.json { }; -in -{ +in { options.programs.foo = { enable = lib.mkEnableOption "foo, a sample program"; package = lib.mkPackageOption pkgs "foo" { }; diff --git a/templates/basic-nix-module-flake/shell.nix b/templates/basic-nix-module-flake/shell.nix index c8b688c1..1d7c9075 100644 --- a/templates/basic-nix-module-flake/shell.nix +++ b/templates/basic-nix-module-flake/shell.nix @@ -2,9 +2,4 @@ with pkgs; -mkShell { - packages = [ - nixpkgs-fmt - treefmt - ]; -} +mkShell { packages = [ nixpkgs-fmt treefmt ]; } diff --git a/templates/basic-overlay-flake/flake.nix b/templates/basic-overlay-flake/flake.nix index 265bcdf4..58b8022c 100644 --- a/templates/basic-overlay-flake/flake.nix +++ b/templates/basic-overlay-flake/flake.nix @@ -9,24 +9,18 @@ }; outputs = inputs@{ self, nixpkgs, ... }: - let - inherit (inputs.flake-utils.lib) defaultSystems eachSystem flattenTree; - in - eachSystem defaultSystems - (system: - let - pkgs = import nixpkgs { inherit system; }; - in - { - devShells.default = - import ./shell.nix { inherit pkgs; }; + let inherit (inputs.flake-utils.lib) defaultSystems eachSystem flattenTree; + in eachSystem defaultSystems (system: + let pkgs = import nixpkgs { inherit system; }; + in { + devShells.default = import ./shell.nix { inherit pkgs; }; - formatter = pkgs.nixpkgs-fmt; + formatter = pkgs.nixpkgs-fmt; - packages = flattenTree (self.overlays.default pkgs pkgs); - }) // { - overlays.default = final: prev: import ./pkgs { pkgs = prev; }; + packages = flattenTree (self.overlays.default pkgs pkgs); + }) // { + overlays.default = final: prev: import ./pkgs { pkgs = prev; }; - nixosModules = { }; - }; + nixosModules = { }; + }; } diff --git a/templates/basic-overlay-flake/shell.nix b/templates/basic-overlay-flake/shell.nix index 212ccd0c..71f952e8 100644 --- a/templates/basic-overlay-flake/shell.nix +++ b/templates/basic-overlay-flake/shell.nix @@ -2,9 +2,4 @@ with pkgs; -mkShell { - packages = [ - rnix-lsp - nixpkgs-fmt - ]; -} +mkShell { packages = [ rnix-lsp nixpkgs-fmt ]; } diff --git a/templates/local-ruby-nix/flake.nix b/templates/local-ruby-nix/flake.nix index a9fe10ad..08fcb9b9 100644 --- a/templates/local-ruby-nix/flake.nix +++ b/templates/local-ruby-nix/flake.nix @@ -22,19 +22,13 @@ ruby = pkgs.ruby_3_1; gemset = ./gemset.nix; }; - in - { - devShells.default = - import ./shell.nix { - inherit pkgs; - extraBuildInputs = [ - gems.env - gems.ruby - ]; - extraPackages = [ - inputs.ruby-nix-bundix.packages."${system}".default - ]; - }; + in { + devShells.default = import ./shell.nix { + inherit pkgs; + extraBuildInputs = [ gems.env gems.ruby ]; + extraPackages = + [ inputs.ruby-nix-bundix.packages."${system}".default ]; + }; formatter = pkgs.treefmt; }); diff --git a/templates/local-ruby-nix/shell.nix b/templates/local-ruby-nix/shell.nix index 998460f1..c073e803 100644 --- a/templates/local-ruby-nix/shell.nix +++ b/templates/local-ruby-nix/shell.nix @@ -1,7 +1,4 @@ -{ pkgs ? import { } -, extraBuildInputs ? [ ] -, extraPackages ? [ ] -}: +{ pkgs ? import { }, extraBuildInputs ? [ ], extraPackages ? [ ] }: with pkgs; diff --git a/templates/rust-app/shell.nix b/templates/rust-app/shell.nix index 9238a441..31a4d345 100644 --- a/templates/rust-app/shell.nix +++ b/templates/rust-app/shell.nix @@ -1,13 +1,8 @@ { pkgs }: -let - app = pkgs.callPackage ./. { }; -in -pkgs.mkShell { +let app = pkgs.callPackage ./. { }; +in pkgs.mkShell { inputsFrom = [ app ]; - packages = with pkgs; [ - treefmt - rust-analyzer - ]; + packages = with pkgs; [ treefmt rust-analyzer ]; } diff --git a/templates/sample-nixos-template/flake.nix b/templates/sample-nixos-template/flake.nix index 98944d2e..74bc7c7b 100644 --- a/templates/sample-nixos-template/flake.nix +++ b/templates/sample-nixos-template/flake.nix @@ -7,18 +7,17 @@ }; outputs = { nixpkgs, home-manager, ... }: - let - system = "x85_64-linux"; - in - { + let system = "x85_64-linux"; + in { nixosConfigurations.desktop = nixpkgs.lib.nixosSystem { inherit system; modules = [ ./hosts/desktop ]; }; - homeConfigurations.foodogsquared = home-manager.lib.homeManagerConfiguration { - pkgs = import nixpkgs { inherit system; }; - modules = [ ./users/foodogsquared ]; - }; + homeConfigurations.foodogsquared = + home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { inherit system; }; + modules = [ ./users/foodogsquared ]; + }; }; } diff --git a/terraform/dns.tf b/terraform/dns.tf index 3ac0d277..2f90bc76 100644 --- a/terraform/dns.tf +++ b/terraform/dns.tf @@ -12,64 +12,64 @@ data "hetznerdns_zone" "main" { resource "hetznerdns_record" "personal_site" { zone_id = data.hetznerdns_zone.main.id - name = "@" - ttl = 3600 - type = "A" - value = "75.2.60.5" + name = "@" + ttl = 3600 + type = "A" + value = "75.2.60.5" } resource "hetznerdns_record" "personal_site_cname" { zone_id = data.hetznerdns_zone.main.id - name = "www" - ttl = 3600 - type = "CNAME" - value = "foodogsquared.netlify.app." + name = "www" + ttl = 3600 + type = "CNAME" + value = "foodogsquared.netlify.app." } resource "hetznerdns_record" "personal_wiki" { zone_id = data.hetznerdns_zone.main.id - name = "wiki" - ttl = 3600 - type = "CNAME" - value = "foodogsquared-wiki.netlify.app." + name = "wiki" + ttl = 3600 + type = "CNAME" + value = "foodogsquared-wiki.netlify.app." } # Mail resources. resource "hetznerdns_record" "mail_mx" { - for_each = toset([ "10 heracles.mxrouting.net.", "20 heracles-relay.mxrouting.net." ]) - zone_id = data.hetznerdns_zone.main.id - name = "@" - type = "MX" - value = each.value + for_each = toset(["10 heracles.mxrouting.net.", "20 heracles-relay.mxrouting.net."]) + zone_id = data.hetznerdns_zone.main.id + name = "@" + type = "MX" + value = each.value } resource "hetznerdns_record" "mail_dmarc" { zone_id = data.hetznerdns_zone.main.id - name = "_dmarc" - ttl = 3600 - type = "TXT" - value = "v=DMARC1;p=none;rua=mailto:postmaster@foodogsquared.one;ruf=mailto:admin@foodogsquared.one" + name = "_dmarc" + ttl = 3600 + type = "TXT" + value = "v=DMARC1;p=none;rua=mailto:postmaster@foodogsquared.one;ruf=mailto:admin@foodogsquared.one" } resource "hetznerdns_record" "mail_dkim" { zone_id = data.hetznerdns_zone.main.id - name = "x._domainkey" - ttl = 3600 - type = "TXT" - value = "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyLlrgdsO4jLncMoGAowlE14oB9R2ESxNLRBtkzc24LOPJ1CwEIE+5AHZd+ZRMwiD7fdXcyCH7/E1BRXWT+TtLnKnBgf5I0z6EbPqiPPb6nmpDWrbZzA2mdKetAKz0kFJC8oYK7lQF7Bdh57y/HWksoH6yjl1E88m8tEQ/thlyABGjqzV+txgmc1BryFu23KasqI2c4We/KgvsoSSAaUHkjpAMCuJck/P0G9mJWyTHrnZN2gCotyenLBZew0BIbiA2XYp6dQW4sU+MawfZ0E1KA0lem0SRYCB+sGD248uj4xVo9sIiCVyO9EQXy/YCZTeuTQHf1+QeFzI82vIrlv63QIDAQAB" + name = "x._domainkey" + ttl = 3600 + type = "TXT" + value = "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyLlrgdsO4jLncMoGAowlE14oB9R2ESxNLRBtkzc24LOPJ1CwEIE+5AHZd+ZRMwiD7fdXcyCH7/E1BRXWT+TtLnKnBgf5I0z6EbPqiPPb6nmpDWrbZzA2mdKetAKz0kFJC8oYK7lQF7Bdh57y/HWksoH6yjl1E88m8tEQ/thlyABGjqzV+txgmc1BryFu23KasqI2c4We/KgvsoSSAaUHkjpAMCuJck/P0G9mJWyTHrnZN2gCotyenLBZew0BIbiA2XYp6dQW4sU+MawfZ0E1KA0lem0SRYCB+sGD248uj4xVo9sIiCVyO9EQXy/YCZTeuTQHf1+QeFzI82vIrlv63QIDAQAB" } resource "hetznerdns_record" "mail_spf" { zone_id = data.hetznerdns_zone.main.id - name = "@" - type = "TXT" - value = "v=spf1 include:mxlogin.com -all" + name = "@" + type = "TXT" + value = "v=spf1 include:mxlogin.com -all" } resource "hetznerdns_record" "mail_webmail" { - for_each = toset([ "mail", "webmail" ]) - zone_id = data.hetznerdns_zone.main.id - name = each.value - type = "CNAME" - value = "heracles.mxrouting.net." + for_each = toset(["mail", "webmail"]) + zone_id = data.hetznerdns_zone.main.id + name = each.value + type = "CNAME" + value = "heracles.mxrouting.net." } diff --git a/terraform/servers.tf b/terraform/servers.tf index 51de3e86..8f98cf20 100644 --- a/terraform/servers.tf +++ b/terraform/servers.tf @@ -7,7 +7,7 @@ provider "hcloud" { } module "hetzner_vps_plover" { - source = "../configs/nixos/plover/terraform" + source = "../configs/nixos/plover/terraform" zone_id = data.hetznerdns_zone.main.id ssh_keys = [ hcloud_ssh_key.foodogsquared.id diff --git a/terraform/tailscale.tf b/terraform/tailscale.tf index a1d35c39..2be56334 100644 --- a/terraform/tailscale.tf +++ b/terraform/tailscale.tf @@ -19,31 +19,31 @@ resource "tailscale_contacts" "default" { resource "tailscale_acl" "basic" { acl = jsonencode({ tagOwners : { - "tag:dev": [ "group:dev" ], - "tag:server": [ "group:admin" ], - "tag:family": [ + "tag:dev" : ["group:dev"], + "tag:server" : ["group:admin"], + "tag:family" : [ "foodogsquared@foodogsquared.one" ], } groups : { - "group:admin": [ "foodogsquared@foodogsquared.one" ], - "group:dev": [ "foodogsquared@foodogsquared.one" ], + "group:admin" : ["foodogsquared@foodogsquared.one"], + "group:dev" : ["foodogsquared@foodogsquared.one"], } ssh : [ { - action: "accept" - src: [ "autogroup:members" ] - dst: [ "autogroup:self" ] - users: [ "autogroup:nonroot" ] + action : "accept" + src : ["autogroup:members"] + dst : ["autogroup:self"] + users : ["autogroup:nonroot"] }, { - action: "accept" - src: [ "group:dev" ] - dst: [ "tag:dev" ] - users: [ "admin" ] + action : "accept" + src : ["group:dev"] + dst : ["tag:dev"] + users : ["admin"] } ] }) - depends_on = [ module.hetzner_vps_plover ] + depends_on = [module.hetzner_vps_plover] } diff --git a/terraform/version.tf b/terraform/version.tf index 8378b9bc..3da5004f 100644 --- a/terraform/version.tf +++ b/terraform/version.tf @@ -6,12 +6,12 @@ terraform { } hetznerdns = { - source = "timohirt/hetznerdns" + source = "timohirt/hetznerdns" version = "2.2.0" } tailscale = { - source = "tailscale/tailscale" + source = "tailscale/tailscale" version = "0.17.2" } } diff --git a/tests/default.nix b/tests/default.nix index bd738ac4..7500ea66 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,13 +1,10 @@ let flakeUtils = import ../lib/flake.nix; flake = flakeUtils.importFlakeMetadata ../flake.lock; -in -{ pkgs ? import (flakeUtils.fetchTree flake "nixos-unstable") { } }: +in { pkgs ? import (flakeUtils.fetchTree flake "nixos-unstable") { } }: -let - utils = import ./utils.nix { inherit pkgs; }; -in -{ +let utils = import ./utils.nix { inherit pkgs; }; +in { lib = import ./lib { inherit pkgs utils; }; modules = { home-manager = import ./modules/home-manager { inherit pkgs utils; }; diff --git a/tests/lib/builders.nix b/tests/lib/builders.nix index 060e4918..5770698a 100644 --- a/tests/lib/builders.nix +++ b/tests/lib/builders.nix @@ -1,105 +1,87 @@ { pkgs, lib, self }: -let - sampleDesktopName = "horizontal-hunger"; -in -lib.runTests { +let sampleDesktopName = "horizontal-hunger"; +in lib.runTests { testsBuilderMakeSampleXDGAssociationList = { - expr = - let - xdgAssociations = self.builders.makeXDGMimeAssociationList { - defaultApplications = { - "application/pdf" = "firefox.desktop"; - }; - }; - in builtins.readFile "${xdgAssociations}/share/applications/mimeapps.list"; - expected = - builtins.readFile ./data/fixtures/xdg-mime-sample-mimeapps.list; + expr = let + xdgAssociations = self.builders.makeXDGMimeAssociationList { + defaultApplications = { "application/pdf" = "firefox.desktop"; }; + }; + in builtins.readFile "${xdgAssociations}/share/applications/mimeapps.list"; + expected = builtins.readFile ./data/fixtures/xdg-mime-sample-mimeapps.list; }; # This should only create the "Default Applications" section of the # specific-desktop mimeapps.list. testsBuilderMakeSampleDesktopSpecificXDGAssociationList = { - expr = - let - xdgAssociations = self.builders.makeXDGMimeAssociationList { - desktopName = sampleDesktopName; - defaultApplications = { - "application/pdf" = "firefox.desktop"; - }; - }; - in builtins.readFile "${xdgAssociations}/share/applications/${sampleDesktopName}-mimeapps.list"; - expected = - builtins.readFile ./data/fixtures/xdg-mime-sample-desktop-specific-mimeapps.list; + expr = let + xdgAssociations = self.builders.makeXDGMimeAssociationList { + desktopName = sampleDesktopName; + defaultApplications = { "application/pdf" = "firefox.desktop"; }; + }; + in builtins.readFile + "${xdgAssociations}/share/applications/${sampleDesktopName}-mimeapps.list"; + expected = builtins.readFile + ./data/fixtures/xdg-mime-sample-desktop-specific-mimeapps.list; }; testsBuilderMakeSampleXDGPortalCommonConfig = { - expr = - let - xdgPortalConf = self.builders.makeXDGPortalConfiguration { - config.preferred = { - default = "gtk"; - "org.freedesktop.impl.portal.Screencast" = "gnome"; - }; + expr = let + xdgPortalConf = self.builders.makeXDGPortalConfiguration { + config.preferred = { + default = "gtk"; + "org.freedesktop.impl.portal.Screencast" = "gnome"; }; - in - builtins.readFile "${xdgPortalConf}/share/xdg-desktop-portal/portals.conf"; - expected = - builtins.readFile ./data/fixtures/xdg-portal.conf; + }; + in builtins.readFile + "${xdgPortalConf}/share/xdg-desktop-portal/portals.conf"; + expected = builtins.readFile ./data/fixtures/xdg-portal.conf; }; # We're just testing out if the destination is correct at this point. testsBuilderMakeSampleXDGPortalDesktopSpecificConfig = { - expr = - let - xdgPortalConf = self.builders.makeXDGPortalConfiguration { - desktopName = sampleDesktopName; - config.preferred = { - default = "gtk"; - "org.freedesktop.impl.portal.Screencast" = "gnome"; - }; + expr = let + xdgPortalConf = self.builders.makeXDGPortalConfiguration { + desktopName = sampleDesktopName; + config.preferred = { + default = "gtk"; + "org.freedesktop.impl.portal.Screencast" = "gnome"; }; - in - builtins.readFile "${xdgPortalConf}/share/xdg-desktop-portal/${sampleDesktopName}-portals.conf"; - expected = - builtins.readFile ./data/fixtures/xdg-portal.conf; + }; + in builtins.readFile + "${xdgPortalConf}/share/xdg-desktop-portal/${sampleDesktopName}-portals.conf"; + expected = builtins.readFile ./data/fixtures/xdg-portal.conf; }; # We're just testing out if the destination is correct at this point. testsBuilderMakeSampleXDGDesktopEntry = { - expr = - let - xdgDesktopEntry = self.builders.makeXDGDesktopEntry { - name = sampleDesktopName; - validate = false; - config = { - "Desktop Entry".Exec = "Hello"; - }; - }; - in - builtins.readFile "${xdgDesktopEntry}/share/applications/${sampleDesktopName}.desktop"; - expected = - builtins.readFile ./data/fixtures/xdg-desktop-entry.desktop; + expr = let + xdgDesktopEntry = self.builders.makeXDGDesktopEntry { + name = sampleDesktopName; + validate = false; + config = { "Desktop Entry".Exec = "Hello"; }; + }; + in builtins.readFile + "${xdgDesktopEntry}/share/applications/${sampleDesktopName}.desktop"; + expected = builtins.readFile ./data/fixtures/xdg-desktop-entry.desktop; }; # We're just testing out if the destination is correct at this point. testsBuilderMakeSampleDesktopSessionFile = { - expr = - let - xdgDesktopEntry = self.builders.makeXDGDesktopEntry { - name = sampleDesktopName; - validate = false; - destination = "/share/wayland-sessions/${sampleDesktopName}.desktop"; - config = { - "Desktop Entry" = { - Exec = "Hello"; - DesktopNames = [ "GNOME" "Sway" ]; - }; + expr = let + xdgDesktopEntry = self.builders.makeXDGDesktopEntry { + name = sampleDesktopName; + validate = false; + destination = "/share/wayland-sessions/${sampleDesktopName}.desktop"; + config = { + "Desktop Entry" = { + Exec = "Hello"; + DesktopNames = [ "GNOME" "Sway" ]; }; }; - in - builtins.readFile "${xdgDesktopEntry}/share/wayland-sessions/${sampleDesktopName}.desktop"; - expected = - builtins.readFile ./data/fixtures/xdg-desktop-session.desktop; + }; + in builtins.readFile + "${xdgDesktopEntry}/share/wayland-sessions/${sampleDesktopName}.desktop"; + expected = builtins.readFile ./data/fixtures/xdg-desktop-session.desktop; }; } diff --git a/tests/lib/data/default.nix b/tests/lib/data/default.nix index 05ce7a48..93f4dd7c 100644 --- a/tests/lib/data/default.nix +++ b/tests/lib/data/default.nix @@ -6,9 +6,7 @@ lib.runTests { expected = { hello = "world"; whoa = 4566; - list-of-names = [ - "Cheesy" "Angry" "Ash" - ]; + list-of-names = [ "Cheesy" "Angry" "Ash" ]; }; }; @@ -17,9 +15,7 @@ lib.runTests { expected = { hello = "world"; whoa = 4566; - list-of-names = [ - "Cheesy" "Angry" "Ash" - ]; + list-of-names = [ "Cheesy" "Angry" "Ash" ]; }; }; diff --git a/tests/lib/default.nix b/tests/lib/default.nix index 4ce462b6..fc32b352 100644 --- a/tests/lib/default.nix +++ b/tests/lib/default.nix @@ -5,18 +5,24 @@ let inherit (pkgs) lib; foodogsquaredLib = (import ../../lib { inherit pkgs; }).extend (final: prev: - let - callLib = file: import file { inherit pkgs lib; self = prev; }; - in - { - nixos = callLib ../../lib/env-specific/nixos.nix; - home-manager = callLib ../../lib/env-specific/home-manager.nix; - nixvim = callLib ../../lib/env-specific/nixvim.nix; - }); + let + callLib = file: + import file { + inherit pkgs lib; + self = prev; + }; + in { + nixos = callLib ../../lib/env-specific/nixos.nix; + home-manager = callLib ../../lib/env-specific/home-manager.nix; + nixvim = callLib ../../lib/env-specific/nixvim.nix; + }); - callLib = file: import file { inherit pkgs lib; self = foodogsquaredLib; }; -in -{ + callLib = file: + import file { + inherit pkgs lib; + self = foodogsquaredLib; + }; +in { builders = callLib ./builders.nix; trivial = callLib ./trivial.nix; data = callLib ./data; diff --git a/tests/lib/fetchers.nix b/tests/lib/fetchers.nix index 545e46e3..9fee45db 100644 --- a/tests/lib/fetchers.nix +++ b/tests/lib/fetchers.nix @@ -1,23 +1,18 @@ -{ - pkgs ? import { }, - lib ? pkgs.lib, - self ? import ../../lib { inherit pkgs; }, -}: +{ pkgs ? import { }, lib ? pkgs.lib +, self ? import ../../lib { inherit pkgs; }, }: { - testsInternetArchiveFetcher = - self.fetchers.fetchInternetArchive { - id = "md_music_sonic_the_hedgehog"; - file = "01 - Title Theme - Masato Nakamura.flac"; - hash = "sha256-kGjsVjtjXK9imqyi4GF6qkFVmobiTAe/ZAeEwiouqS4="; - }; + testsInternetArchiveFetcher = self.fetchers.fetchInternetArchive { + id = "md_music_sonic_the_hedgehog"; + file = "01 - Title Theme - Masato Nakamura.flac"; + hash = "sha256-kGjsVjtjXK9imqyi4GF6qkFVmobiTAe/ZAeEwiouqS4="; + }; - testsInternetArchiveFetcher2 = - self.fetchers.fetchInternetArchive { - id = "md_music_sonic_the_hedgehog"; - formats = [ "TEXT" "PNG" ]; - hash = "sha256-xbhasJ/wEgcY+EcBAJp5UoYB4N4It3QV/iIeGGdCET8="; - }; + testsInternetArchiveFetcher2 = self.fetchers.fetchInternetArchive { + id = "md_music_sonic_the_hedgehog"; + formats = [ "TEXT" "PNG" ]; + hash = "sha256-xbhasJ/wEgcY+EcBAJp5UoYB4N4It3QV/iIeGGdCET8="; + }; testsFetchUgeeDriver = # Ugee M908. diff --git a/tests/lib/home-manager.nix b/tests/lib/home-manager.nix index b1fad94c..b36a5a1b 100644 --- a/tests/lib/home-manager.nix +++ b/tests/lib/home-manager.nix @@ -3,11 +3,7 @@ let # We're just using stub configurations instead. nixosConfig = { - programs = { - firefox = { - enable = true; - }; - }; + programs = { firefox = { enable = true; }; }; services = { pipewire = { @@ -26,10 +22,7 @@ let activitywatch.enable = true; bleachbit = { enable = true; - cleaners = [ - "firefox.cookies" - "discord.cache" - ]; + cleaners = [ "firefox.cookies" "discord.cache" ]; }; }; }; @@ -38,20 +31,29 @@ let inherit nixosConfig; osConfig = nixosConfig; } // hmConfig; -in -lib.runTests { +in lib.runTests { testHomeManagerStandaloneEmpty = { - expr = self.home-manager.hasNixOSConfigAttr { } [ "programs" "firefox" "enable" ] false; + expr = + self.home-manager.hasNixOSConfigAttr { } [ "programs" "firefox" "enable" ] + false; expected = false; }; testHomeManagerStandalone = { - expr = self.home-manager.hasNixOSConfigAttr hmConfig [ "programs" "firefox" "enable" ] false; + expr = self.home-manager.hasNixOSConfigAttr hmConfig [ + "programs" + "firefox" + "enable" + ] false; expected = false; }; testHomeManagerWithinNixOS = { - expr = self.home-manager.hasNixOSConfigAttr hmConfig' [ "programs" "firefox" "enable" ] false; + expr = self.home-manager.hasNixOSConfigAttr hmConfig' [ + "programs" + "firefox" + "enable" + ] false; expected = true; }; } diff --git a/tests/lib/math.nix b/tests/lib/math.nix index 32ec4d14..8308afbb 100644 --- a/tests/lib/math.nix +++ b/tests/lib/math.nix @@ -1,6 +1,5 @@ { pkgs, lib, self }: - lib.runTests { testMathAbsoluteValue = { expr = self.math.abs 5493; diff --git a/tests/lib/nixos.nix b/tests/lib/nixos.nix index 25d0ffe9..37b4cb8b 100644 --- a/tests/lib/nixos.nix +++ b/tests/lib/nixos.nix @@ -1,11 +1,7 @@ { pkgs, lib, self }: -let - testConfig = { - formatAttr = "isoImage"; - }; -in -lib.runTests { +let testConfig = { formatAttr = "isoImage"; }; +in lib.runTests { testNixSystemHasFormat = { expr = self.nixos.hasNixosFormat testConfig; expected = true; diff --git a/tests/lib/nixvim.nix b/tests/lib/nixvim.nix index 7d6bcc33..cd25cf59 100644 --- a/tests/lib/nixvim.nix +++ b/tests/lib/nixvim.nix @@ -7,15 +7,10 @@ let plugins.neorg.enable = true; }; - nixosConfig = { - programs.firefox.enable = true; - }; + nixosConfig = { programs.firefox.enable = true; }; - nixvimConfig' = { - inherit nixosConfig; - } // nixvimConfig; -in -lib.runTests { + nixvimConfig' = { inherit nixosConfig; } // nixvimConfig; +in lib.runTests { testNixvimIsStandalone = { expr = self.nixvim.isStandalone nixvimConfig; expected = true; diff --git a/tests/lib/trivial.nix b/tests/lib/trivial.nix index ae63e92a..8c5ef682 100644 --- a/tests/lib/trivial.nix +++ b/tests/lib/trivial.nix @@ -12,7 +12,7 @@ lib.runTests { }; testCountAttrs = { - expr = self.trivial.countAttrs (n: v: v?enable && v.enable) { + expr = self.trivial.countAttrs (n: v: v ? enable && v.enable) { hello.enable = true; what.enable = false; atro.enable = true; @@ -31,7 +31,10 @@ lib.runTests { }; expected = { ok = { a = 4; }; - notOk = { e = 5; f = 7; }; + notOk = { + e = 5; + f = 7; + }; }; }; diff --git a/tests/modules/home-manager/default.nix b/tests/modules/home-manager/default.nix index a2c7e7d8..e02b0de0 100644 --- a/tests/modules/home-manager/default.nix +++ b/tests/modules/home-manager/default.nix @@ -1,10 +1,7 @@ # We're basically reimplmenting parts from the home-manager test suite here # just with our own modules included. -{ pkgs ? import { } -, utils ? import ../../utils.nix { inherit pkgs; } -, homeManagerSrc ? -, enableBig ? true -}: +{ pkgs ? import { }, utils ? import ../../utils.nix { inherit pkgs; } +, homeManagerSrc ? , enableBig ? true }: let nmt = pkgs.nix-lib-nmt; @@ -47,8 +44,7 @@ let ]; inherit (pkgs.stdenv.hostPlatform) isDarwin isLinux; -in -import nmt { +in import nmt { inherit pkgs lib modules; testedAttrPath = [ "home" "activationPackage" ]; # TODO: Fix nmt to accept specialArgs or something. @@ -57,8 +53,7 @@ import nmt { ./programs/pipewire ./programs/pop-launcher ./programs/zed-editor - ] - ++ lib.optionals isLinux [ + ] ++ lib.optionals isLinux [ ./services/archivebox #./services/borgmatic ./services/bleachbit diff --git a/tests/modules/home-manager/programs/borgmatic/basic.nix b/tests/modules/home-manager/programs/borgmatic/basic.nix index 27fd3dff..6ed477e3 100644 --- a/tests/modules/home-manager/programs/borgmatic/basic.nix +++ b/tests/modules/home-manager/programs/borgmatic/basic.nix @@ -4,13 +4,9 @@ programs.borgmatic = { enable = true; backups = { - personal.settings = { - hello = "WORLD"; - }; + personal.settings = { hello = "WORLD"; }; - bizness.settings = { - hello = "MONEY"; - }; + bizness.settings = { hello = "MONEY"; }; }; }; diff --git a/tests/modules/home-manager/programs/pipewire/basic.nix b/tests/modules/home-manager/programs/pipewire/basic.nix index 5909b35d..a6df7d8b 100644 --- a/tests/modules/home-manager/programs/pipewire/basic.nix +++ b/tests/modules/home-manager/programs/pipewire/basic.nix @@ -16,7 +16,7 @@ nvidia-ai-what = { hawk-hawk = true; reduce-muffled-sounds = true; - noise-gate = 5.60; + noise-gate = 5.6; abc = [ "d" "e" "f" ]; }; }; diff --git a/tests/modules/home-manager/services/archivebox/basic-job.nix b/tests/modules/home-manager/services/archivebox/basic-job.nix index 1b9c754d..31d51233 100644 --- a/tests/modules/home-manager/services/archivebox/basic-job.nix +++ b/tests/modules/home-manager/services/archivebox/basic-job.nix @@ -6,10 +6,8 @@ archivePath = "${config.xdg.userDirs.documents}/ArchiveBox"; jobs.art = { - links = [ - "https://www.davidrevoy.com/" - "https://www.youtube.com/c/ronillust" - ]; + links = + [ "https://www.davidrevoy.com/" "https://www.youtube.com/c/ronillust" ]; startAt = "weekly"; }; }; diff --git a/tests/modules/home-manager/services/archivebox/multiple-jobs.nix b/tests/modules/home-manager/services/archivebox/multiple-jobs.nix index 564de5b3..50d2cd1b 100644 --- a/tests/modules/home-manager/services/archivebox/multiple-jobs.nix +++ b/tests/modules/home-manager/services/archivebox/multiple-jobs.nix @@ -15,10 +15,7 @@ }; research = { - links = [ - "https://arxiv.org/rss/cs" - "https://distill.pub/" - ]; + links = [ "https://arxiv.org/rss/cs" "https://distill.pub/" ]; extraArgs = [ "--depth" "1" ]; startAt = "daily"; }; diff --git a/tests/modules/home-manager/services/archivebox/webserver.nix b/tests/modules/home-manager/services/archivebox/webserver.nix index 33d4f48d..92603ce8 100644 --- a/tests/modules/home-manager/services/archivebox/webserver.nix +++ b/tests/modules/home-manager/services/archivebox/webserver.nix @@ -6,10 +6,8 @@ archivePath = "${config.xdg.userDirs.documents}/ArchiveBox"; jobs.art = { - links = [ - "https://www.davidrevoy.com/" - "https://www.youtube.com/c/ronillust" - ]; + links = + [ "https://www.davidrevoy.com/" "https://www.youtube.com/c/ronillust" ]; startAt = "weekly"; }; diff --git a/tests/modules/home-manager/services/bleachbit/basic-setup.nix b/tests/modules/home-manager/services/bleachbit/basic-setup.nix index 33dcc530..20d74e5f 100644 --- a/tests/modules/home-manager/services/bleachbit/basic-setup.nix +++ b/tests/modules/home-manager/services/bleachbit/basic-setup.nix @@ -4,12 +4,8 @@ services.bleachbit = { enable = true; startAt = "weekly"; - cleaners = [ - "firefox.cookies" - "firefox.history" - "discord.logs" - "zoom.logs" - ]; + cleaners = + [ "firefox.cookies" "firefox.history" "discord.logs" "zoom.logs" ]; }; test.stubs.bleachbit = { }; diff --git a/tests/modules/home-manager/services/bleachbit/default.nix b/tests/modules/home-manager/services/bleachbit/default.nix index 0f713ffa..e2989c2d 100644 --- a/tests/modules/home-manager/services/bleachbit/default.nix +++ b/tests/modules/home-manager/services/bleachbit/default.nix @@ -1,3 +1 @@ -{ - bleachbit-basic-setup = ./basic-setup.nix; -} +{ bleachbit-basic-setup = ./basic-setup.nix; } diff --git a/tests/modules/home-manager/services/borgmatic/basic.nix b/tests/modules/home-manager/services/borgmatic/basic.nix index 1a36ade0..ab504671 100644 --- a/tests/modules/home-manager/services/borgmatic/basic.nix +++ b/tests/modules/home-manager/services/borgmatic/basic.nix @@ -1,11 +1,7 @@ { config, lib, pkgs, ... }: { - services.borgmatic.jobs.personal = { - settings = { - hello = "WORLD"; - }; - }; + services.borgmatic.jobs.personal = { settings = { hello = "WORLD"; }; }; test.stubs.borgmatic = { }; diff --git a/tests/modules/home-manager/services/gallery-dl/basic-job.nix b/tests/modules/home-manager/services/gallery-dl/basic-job.nix index 7e9f6525..ef6ba35f 100644 --- a/tests/modules/home-manager/services/gallery-dl/basic-job.nix +++ b/tests/modules/home-manager/services/gallery-dl/basic-job.nix @@ -10,8 +10,10 @@ "--download-archive" "${config.services.gallery-dl.archivePath}/photos" - "--date" "today-1week" # get only videos from a week ago - "--output" "%(uploader)s/%(title)s.%(ext)s" # download them in the respective directory + "--date" + "today-1week" # get only videos from a week ago + "--output" + "%(uploader)s/%(title)s.%(ext)s" # download them in the respective directory ]; jobs.art = { diff --git a/tests/modules/home-manager/services/gallery-dl/multiple-jobs.nix b/tests/modules/home-manager/services/gallery-dl/multiple-jobs.nix index 172c082c..74263896 100644 --- a/tests/modules/home-manager/services/gallery-dl/multiple-jobs.nix +++ b/tests/modules/home-manager/services/gallery-dl/multiple-jobs.nix @@ -10,8 +10,10 @@ "--download-archive" "${config.services.gallery-dl.archivePath}/photos" - "--date" "today-1week" # get only videos from a week ago - "--output" "%(uploader)s/%(title)s.%(ext)s" # download them in the respective directory + "--date" + "today-1week" # get only videos from a week ago + "--output" + "%(uploader)s/%(title)s.%(ext)s" # download them in the respective directory ]; jobs = { @@ -29,7 +31,8 @@ ]; startAt = "daily"; extraArgs = [ - "--date" "today-2week" # get only videos from a week ago + "--date" + "today-2week" # get only videos from a week ago ]; }; }; diff --git a/tests/modules/home-manager/services/gonic/default.nix b/tests/modules/home-manager/services/gonic/default.nix index 10ef0b68..9804a89e 100644 --- a/tests/modules/home-manager/services/gonic/default.nix +++ b/tests/modules/home-manager/services/gonic/default.nix @@ -1,3 +1 @@ -{ - gonic-basic = ./basic.nix; -} +{ gonic-basic = ./basic.nix; } diff --git a/tests/modules/home-manager/services/ludusavi/basic.nix b/tests/modules/home-manager/services/ludusavi/basic.nix index 0179e568..c15b2b7a 100644 --- a/tests/modules/home-manager/services/ludusavi/basic.nix +++ b/tests/modules/home-manager/services/ludusavi/basic.nix @@ -3,13 +3,10 @@ { services.ludusavi = { enable = true; - extraArgs = [ - "--force" - "--compression zstd" - "--compression-level 15" - ]; + extraArgs = [ "--force" "--compression zstd" "--compression-level 15" ]; settings = { - manifest.url = "https://raw.githubusercontent.com/mtkennerly/ludusavi-manifest/master/data/manifest.yaml"; + manifest.url = + "https://raw.githubusercontent.com/mtkennerly/ludusavi-manifest/master/data/manifest.yaml"; backup.path = "${config.xdg.cacheHome}/ludusavi/backups"; restore.path = "${config.xdg.cacheHome}/ludusavi/backups"; }; diff --git a/tests/modules/home-manager/services/ludusavi/default.nix b/tests/modules/home-manager/services/ludusavi/default.nix index 15183c4b..cb6302a7 100644 --- a/tests/modules/home-manager/services/ludusavi/default.nix +++ b/tests/modules/home-manager/services/ludusavi/default.nix @@ -1,3 +1 @@ -{ - ludusavi-basic = ./basic.nix; -} +{ ludusavi-basic = ./basic.nix; } diff --git a/tests/modules/home-manager/services/matcha/default.nix b/tests/modules/home-manager/services/matcha/default.nix index 2b380e28..bd2091c6 100644 --- a/tests/modules/home-manager/services/matcha/default.nix +++ b/tests/modules/home-manager/services/matcha/default.nix @@ -1,3 +1 @@ -{ - matcha-basic = ./basic.nix; -} +{ matcha-basic = ./basic.nix; } diff --git a/tests/modules/home-manager/services/openrefine/default.nix b/tests/modules/home-manager/services/openrefine/default.nix index e04989e7..0f9af33d 100644 --- a/tests/modules/home-manager/services/openrefine/default.nix +++ b/tests/modules/home-manager/services/openrefine/default.nix @@ -1,3 +1 @@ -{ - openrefine-basic = ./basic.nix; -} +{ openrefine-basic = ./basic.nix; } diff --git a/tests/modules/home-manager/services/plover/basic-service.nix b/tests/modules/home-manager/services/plover/basic-service.nix index 8874ad10..63854cdc 100644 --- a/tests/modules/home-manager/services/plover/basic-service.nix +++ b/tests/modules/home-manager/services/plover/basic-service.nix @@ -5,13 +5,9 @@ enable = true; package = pkgs.plover-dev; settings = { - "Output Configuration" = { - undo_levels = 100; - }; + "Output Configuration" = { undo_levels = 100; }; - "Stroke Display" = { - show = true; - }; + "Stroke Display" = { show = true; }; }; }; diff --git a/tests/modules/home-manager/services/plover/default.nix b/tests/modules/home-manager/services/plover/default.nix index 27ec3814..b3edb146 100644 --- a/tests/modules/home-manager/services/plover/default.nix +++ b/tests/modules/home-manager/services/plover/default.nix @@ -1,3 +1 @@ -{ - plover-basic-service = ./basic-service.nix; -} +{ plover-basic-service = ./basic-service.nix; } diff --git a/tests/modules/home-manager/services/yt-dlp/multiple-jobs.nix b/tests/modules/home-manager/services/yt-dlp/multiple-jobs.nix index b9287421..dfd2a67b 100644 --- a/tests/modules/home-manager/services/yt-dlp/multiple-jobs.nix +++ b/tests/modules/home-manager/services/yt-dlp/multiple-jobs.nix @@ -25,9 +25,7 @@ }; music = { - extraArgs = [ - "--extract-audio" - ]; + extraArgs = [ "--extract-audio" ]; urls = [ "https://www.youtube.com/@dragonforce" "https://www.youtube.com/channel/UCjZjUymRDAhp9c1rb0X6aww" # 500L/g diff --git a/tests/modules/wrapper-manager/dconf/basic.nix b/tests/modules/wrapper-manager/dconf/basic.nix index bd32dff3..7f1f050b 100644 --- a/tests/modules/wrapper-manager/dconf/basic.nix +++ b/tests/modules/wrapper-manager/dconf/basic.nix @@ -4,8 +4,7 @@ let section = "one/foodogsquared/SomeMadeUpCrap"; key = "somemadeupkey"; value = true; -in -{ +in { wrappers.dconf-test = { arg0 = lib.getExe' pkgs.dconf "dconf"; dconf = { @@ -20,7 +19,9 @@ in # We've hardcoded the value for now since Nix toString function makes the # boolean either "1" or an empty string. - [ "$(${lib.getExe' config.build.toplevel "dconf-test"} read '/${section}/${key}')" = 'true' ] && touch $out + [ "$(${ + lib.getExe' config.build.toplevel "dconf-test" + } read '/${section}/${key}')" = 'true' ] && touch $out ''; }; } diff --git a/tests/modules/wrapper-manager/dconf/default.nix b/tests/modules/wrapper-manager/dconf/default.nix index 7fff7787..18cf47cf 100644 --- a/tests/modules/wrapper-manager/dconf/default.nix +++ b/tests/modules/wrapper-manager/dconf/default.nix @@ -1,3 +1 @@ -{ - basic = ./basic.nix; -} +{ basic = ./basic.nix; } diff --git a/tests/modules/wrapper-manager/default.nix b/tests/modules/wrapper-manager/default.nix index fe29b381..d46f5147 100644 --- a/tests/modules/wrapper-manager/default.nix +++ b/tests/modules/wrapper-manager/default.nix @@ -1,21 +1,22 @@ -{ pkgs ? import { }, utils ? import ../../utils.nix { inherit pkgs; } }: +{ pkgs ? import { }, utils ? import ../../utils.nix { inherit pkgs; } +}: let inherit (pkgs) lib; wrapperManager = import ../../../subprojects/wrapper-manager-fds { }; - wrapperManagerEval = module: args: wrapperManager.lib.build (args // { - pkgs = args.pkgs or pkgs; - modules = args.extraModules or [ ] ++ [ - module - ../../../modules/wrapper-manager - ../../../modules/wrapper-manager/_private - ]; - }); + wrapperManagerEval = module: args: + wrapperManager.lib.build (args // { + pkgs = args.pkgs or pkgs; + modules = args.extraModules or [ ] ++ [ + module + ../../../modules/wrapper-manager + ../../../modules/wrapper-manager/_private + ]; + }); runTests = path: args: lib.mapAttrs (_: v: wrapperManagerEval v args) (import path); -in -{ +in { neovim = runTests ./programs/neovim { }; bubblewrap = runTests ./sandboxing/bubblewrap { }; boxxy = runTests ./sandboxing/boxxy { }; diff --git a/tests/modules/wrapper-manager/programs/jujutsu/basic.nix b/tests/modules/wrapper-manager/programs/jujutsu/basic.nix index 19fdb285..81928951 100644 --- a/tests/modules/wrapper-manager/programs/jujutsu/basic.nix +++ b/tests/modules/wrapper-manager/programs/jujutsu/basic.nix @@ -10,12 +10,10 @@ }; build.extraPassthru.tests = { - runWithJujutsu = let - wrapper = config.build.toplevel; + runWithJujutsu = let wrapper = config.build.toplevel; in pkgs.runCommand '' [ -x ${lib.getExe' wrapper "jj"} ] && touch $out ''; }; } - diff --git a/tests/modules/wrapper-manager/programs/jujutsu/default.nix b/tests/modules/wrapper-manager/programs/jujutsu/default.nix index 7fff7787..18cf47cf 100644 --- a/tests/modules/wrapper-manager/programs/jujutsu/default.nix +++ b/tests/modules/wrapper-manager/programs/jujutsu/default.nix @@ -1,3 +1 @@ -{ - basic = ./basic.nix; -} +{ basic = ./basic.nix; } diff --git a/tests/modules/wrapper-manager/programs/neovim/basic.nix b/tests/modules/wrapper-manager/programs/neovim/basic.nix index c53b0772..3f8037b5 100644 --- a/tests/modules/wrapper-manager/programs/neovim/basic.nix +++ b/tests/modules/wrapper-manager/programs/neovim/basic.nix @@ -1,13 +1,10 @@ { config, lib, pkgs, ... }: { - programs.neovim = { - enable = true; - }; + programs.neovim = { enable = true; }; build.extraPassthru.tests = { - runWithNeovim = let - wrapper = config.build.toplevel; + runWithNeovim = let wrapper = config.build.toplevel; in pkgs.runCommand '' [ -x ${lib.getExe' wrapper "nvim"} ] && touch $out ''; diff --git a/tests/modules/wrapper-manager/programs/neovim/default.nix b/tests/modules/wrapper-manager/programs/neovim/default.nix index 7fff7787..18cf47cf 100644 --- a/tests/modules/wrapper-manager/programs/neovim/default.nix +++ b/tests/modules/wrapper-manager/programs/neovim/default.nix @@ -1,3 +1 @@ -{ - basic = ./basic.nix; -} +{ basic = ./basic.nix; } diff --git a/tests/modules/wrapper-manager/programs/zellij/basic.nix b/tests/modules/wrapper-manager/programs/zellij/basic.nix index 3a7a5b58..1378cf17 100644 --- a/tests/modules/wrapper-manager/programs/zellij/basic.nix +++ b/tests/modules/wrapper-manager/programs/zellij/basic.nix @@ -5,10 +5,12 @@ programs.zellij.configFile = ./config/config.kdl; build.extraPassthru.tests = { - checkZellijConfigDir = let - wrapper = lib.getExe' config.build.toplevel "zellij"; - in pkgs.runCommandLocal "zellij-check-config-dir" { } '' - [ $(${wrapper} setup --check | awk -F':' '/^\[LOOKING FOR CONFIG FILE FROM]/ { gsub(/"|\s/, "", $2); print $2; }') = ${./config/config.kdl} ] && touch $out - ''; + checkZellijConfigDir = + let wrapper = lib.getExe' config.build.toplevel "zellij"; + in pkgs.runCommandLocal "zellij-check-config-dir" { } '' + [ $(${wrapper} setup --check | awk -F':' '/^\[LOOKING FOR CONFIG FILE FROM]/ { gsub(/"|\s/, "", $2); print $2; }') = ${ + ./config/config.kdl + } ] && touch $out + ''; }; } diff --git a/tests/modules/wrapper-manager/programs/zellij/default.nix b/tests/modules/wrapper-manager/programs/zellij/default.nix index 7fff7787..18cf47cf 100644 --- a/tests/modules/wrapper-manager/programs/zellij/default.nix +++ b/tests/modules/wrapper-manager/programs/zellij/default.nix @@ -1,3 +1 @@ -{ - basic = ./basic.nix; -} +{ basic = ./basic.nix; } diff --git a/tests/modules/wrapper-manager/sandboxing/boxxy/basic.nix b/tests/modules/wrapper-manager/sandboxing/boxxy/basic.nix index 35c45e43..ce782148 100644 --- a/tests/modules/wrapper-manager/sandboxing/boxxy/basic.nix +++ b/tests/modules/wrapper-manager/sandboxing/boxxy/basic.nix @@ -16,7 +16,8 @@ wraparound.variant = "boxxy"; wraparound.subwrapper.arg0 = lib.getExe' pkgs.zellij "zellij"; wraparound.boxxy.rules = { - "$XDG_CONFIG_HOME/zellij/hello.kdl".source = "$XDG_CONFIG_HOME/zellij/config.kdl"; + "$XDG_CONFIG_HOME/zellij/hello.kdl".source = + "$XDG_CONFIG_HOME/zellij/config.kdl"; }; }; } diff --git a/tests/modules/wrapper-manager/sandboxing/boxxy/default.nix b/tests/modules/wrapper-manager/sandboxing/boxxy/default.nix index 7fff7787..18cf47cf 100644 --- a/tests/modules/wrapper-manager/sandboxing/boxxy/default.nix +++ b/tests/modules/wrapper-manager/sandboxing/boxxy/default.nix @@ -1,3 +1 @@ -{ - basic = ./basic.nix; -} +{ basic = ./basic.nix; } diff --git a/tests/modules/wrapper-manager/sandboxing/bubblewrap/basic-zellij.nix b/tests/modules/wrapper-manager/sandboxing/bubblewrap/basic-zellij.nix index 7e57c96b..484f576b 100644 --- a/tests/modules/wrapper-manager/sandboxing/bubblewrap/basic-zellij.nix +++ b/tests/modules/wrapper-manager/sandboxing/bubblewrap/basic-zellij.nix @@ -7,12 +7,10 @@ wraparound.subwrapper.arg0 = lib.getExe' pkgs.zellij "zellij"; }; build.extraPassthru.tests = { - zellijWrapperCheck = - let - wrapper = config.build.toplevel; - in pkgs.runCommand { } '' - [ -x ${lib.getExe' wrapper "zellij"} ] && touch $out + zellijWrapperCheck = let wrapper = config.build.toplevel; + in pkgs.runCommand { } '' + [ -x ${lib.getExe' wrapper "zellij"} ] && touch $out - ''; + ''; }; } diff --git a/tests/utils.nix b/tests/utils.nix index 81601164..4e4eb733 100644 --- a/tests/utils.nix +++ b/tests/utils.nix @@ -4,8 +4,7 @@ let nixpkgsPath = pkgs.path; nixosLib = import "${nixpkgsPath}/nixos/lib" { }; -in -rec { +in rec { # We're not using this to test the hosts configuration (that would be # atrocious). We're only using this for NixOS modules. nixosTest = test: