diff --git a/default.nix b/default.nix index eea5e362..6ae24450 100644 --- a/default.nix +++ b/default.nix @@ -3,7 +3,8 @@ let lib' = pkgs.lib.extend (final: prev: import ./lib { lib = prev; } // import ./lib/private.nix { lib = final; }); -in { +in +{ lib = import ./lib { lib = pkgs.lib; }; modules = lib'.importModules (lib'.filesToAttr ./modules/nixos); overlays.foo-dogsquared-pkgs = final: prev: import ./pkgs { pkgs = prev; }; diff --git a/flake.nix b/flake.nix index 2c55c330..952f9119 100644 --- a/flake.nix +++ b/flake.nix @@ -395,15 +395,17 @@ # Take note for automatically imported nodes, various options should be # overridden in the deploy utility considering that most have only # certain values and likely not work if run with the intended value. - deploy.nodes = (lib'.mapAttrs' (name: value: - lib'.nameValuePair name { - hostname = name; - profiles.system = { - sshUser = "admin"; - user = "root"; - path = inputs.deploy.lib.${defaultSystem}.activate.nixos value; - }; - }) self.nixosConfigurations); + deploy.nodes = (lib'.mapAttrs' + (name: value: + lib'.nameValuePair name { + hostname = name; + profiles.system = { + sshUser = "admin"; + user = "root"; + path = inputs.deploy.lib.${defaultSystem}.activate.nixos value; + }; + }) + self.nixosConfigurations); # How to make yourself slightly saner than before. So far the main checks # are for deploy nodes. diff --git a/lib/default.nix b/lib/default.nix index ec03d2eb..5459b5e2 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -31,17 +31,19 @@ rec { collect = file: type: { name = lib.removeSuffix ".nix" file; - value = let path = dirPath + "/${file}"; - in if (type == "regular") - || (type == "directory" && lib.pathExists (path + "/default.nix")) then - path - else - filesToAttr path; + value = + let path = dirPath + "/${file}"; + in if (type == "regular") + || (type == "directory" && lib.pathExists (path + "/default.nix")) then + path + else + filesToAttr path; }; files = lib.filterAttrs isModule (builtins.readDir dirPath); - in lib.filterAttrs (name: value: value != { }) - (lib.mapAttrs' collect files); + in + lib.filterAttrs (name: value: value != { }) + (lib.mapAttrs' collect files); /* Collect all modules (results from `filesToAttr`) into a list. @@ -71,5 +73,5 @@ rec { */ countAttrs = pred: attrs: lib.count (attr: pred attr.name attr.value) - (lib.mapAttrsToList lib.nameValuePair attrs); + (lib.mapAttrsToList lib.nameValuePair attrs); } diff --git a/lib/private.nix b/lib/private.nix index 5c017ff0..750d68ad 100644 --- a/lib/private.nix +++ b/lib/private.nix @@ -14,12 +14,13 @@ rec { # TODO: Effectively override the option. # We assume all users set with this module are normal users. absoluteOverrides = { isNormalUser = true; }; - in { + in + { home-manager.users."${user}" = { ... }: { imports = [ (getUser "home-manager" user) ]; }; users.users."${user}" = defaultUserConfig // settings // absoluteOverrides; - }; + }; getSecret = path: ../secrets/${path}; @@ -32,25 +33,28 @@ rec { userList = lib.attrNames users'; nonExistentUsers = lib.filter (name: !lib.elem name userList) users; - in lib.trivial.throwIfNot ((lib.length nonExistentUsers) == 0) + in + lib.trivial.throwIfNot ((lib.length nonExistentUsers) == 0) "there are no users ${lib.concatMapStringsSep ", " (u: "'${u}'") nonExistentUsers} from ${type}" - (r: r) users'; + (r: r) + users'; getUser = type: user: lib.getAttr user (getUsers type [ user ]); # Import modules with a set blocklist. - importModules = attrs: let - blocklist = [ - # The modules under this attribute are often incomplete and needing - # very specific requirements that is 99% going to be absent from the - # outside so we're not going to export it. - "tasks" + importModules = attrs: + let + blocklist = [ + # The modules under this attribute are often incomplete and needing + # very specific requirements that is 99% going to be absent from the + # outside so we're not going to export it. + "tasks" - # Profiles are often specific to this project so there's not much point - # in exporting these. - "profiles" - ]; - in - lib.filterAttrs (n: v: !lib.elem n blocklist) (lib.mapAttrsRecursive (_: path: import path) attrs); + # Profiles are often specific to this project so there's not much point + # in exporting these. + "profiles" + ]; + in + lib.filterAttrs (n: v: !lib.elem n blocklist) (lib.mapAttrsRecursive (_: path: import path) attrs); } diff --git a/modules/home-manager/programs/pop-launcher.nix b/modules/home-manager/programs/pop-launcher.nix index e7968f54..5e88c505 100644 --- a/modules/home-manager/programs/pop-launcher.nix +++ b/modules/home-manager/programs/pop-launcher.nix @@ -15,9 +15,11 @@ let # Some plugins may be packaged ala-busybox with multiple plugins coming from # the same binary. Similar reasons as to why we don't want to rewrite # symlinks with the main package. - plugins = lib.map (p: p.overrideAttrs (prev: { - dontRewriteSymlinks = true; - })) cfg.plugins; + plugins = lib.map + (p: p.overrideAttrs (prev: { + dontRewriteSymlinks = true; + })) + cfg.plugins; # Plugins and scripts are assumed to be packaged at # `$out/share/pop-launcher`. @@ -57,7 +59,7 @@ in List of packages containing Pop launcher plugins and scripts to be installed as system-wide plugins. ''; - default = []; + default = [ ]; defaultText = "[]"; example = lib.literalExpression '' with pkgs; [ diff --git a/modules/home-manager/services/archivebox.nix b/modules/home-manager/services/archivebox.nix index dfd384ef..056a679b 100644 --- a/modules/home-manager/services/archivebox.nix +++ b/modules/home-manager/services/archivebox.nix @@ -40,7 +40,8 @@ let }; }; }; -in { +in +{ options.services.archivebox = { enable = lib.mkEnableOption "Archivebox service"; @@ -92,81 +93,89 @@ 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.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.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} - ''; + 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.target"; + Documentation = [ "https://docs.archivebox.io/" ]; }; - 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.target"; - Documentation = [ "https://docs.archivebox.io/" ]; - }; + Install.WantedBy = [ "graphical-session.target" ]; - Install.WantedBy = [ "graphical-session.target" ]; - - Service = { - ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${ + 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.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.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 3d849764..c5f627ce 100644 --- a/modules/home-manager/services/bleachbit.nix +++ b/modules/home-manager/services/bleachbit.nix @@ -47,7 +47,8 @@ let "thunderbird.passwords" "thunderbird.sessionjson" ]; -in { +in +{ options.services.bleachbit = { enable = lib.mkEnableOption "automated cleanup with Bleachbit"; startAt = lib.mkOption { @@ -81,7 +82,7 @@ in { cleaners = lib.mkOption { type = with lib.types; listOf str; description = "List of cleaners to be used when cleaning."; - default = []; + default = [ ]; example = lib.literalExpression '' [ "bash.history" @@ -111,7 +112,7 @@ in { }; Service.ExecStart = '' - ${cfg.package}/bin/bleachbit --clean ${lib.escapeShellArgs cleaners} + ${cfg.package}/bin/bleachbit --clean ${lib.escapeShellArgs cleaners} ''; }; diff --git a/modules/home-manager/services/gallery-dl.nix b/modules/home-manager/services/gallery-dl.nix index 60db23ed..da32834a 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 = { @@ -82,7 +82,8 @@ let }; }; }; -in { +in +{ options.services.gallery-dl = { enable = lib.mkEnableOption "archiving services with gallery-dl"; @@ -163,47 +164,53 @@ 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/plover.nix b/modules/home-manager/services/plover.nix index 737ef2c3..9e68e2ea 100644 --- a/modules/home-manager/services/plover.nix +++ b/modules/home-manager/services/plover.nix @@ -5,24 +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 { }; -in { +in +{ options.services.plover = { enable = lib.mkEnableOption "Plover stenography engine service"; @@ -74,7 +76,7 @@ in { xdg.configFile."plover/plover.cfg".source = settingsFormat.generate "plover-config-${config.home.username}" - cfg.settings; + cfg.settings; systemd.user.services.plover = { Unit = { diff --git a/modules/home-manager/services/yt-dlp.nix b/modules/home-manager/services/yt-dlp.nix index c033af34..7650fc90 100644 --- a/modules/home-manager/services/yt-dlp.nix +++ b/modules/home-manager/services/yt-dlp.nix @@ -63,7 +63,8 @@ let }; }; }; -in { +in +{ options.services.yt-dlp = { enable = lib.mkEnableOption "archiving service with yt-dlp"; @@ -135,49 +136,55 @@ 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 - }" - ''; - ExecStart = let - scriptName = - "yt-dlp-archive-service-${config.home.username}-${name}"; - jobLevelArgs = lib.escapeShellArgs value.extraArgs; - urls = lib.escapeShellArgs urls; - archiveScript = pkgs.writeShellScriptBin scriptName '' - ${cfg.package}/bin/yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \ - ${urls} --paths ${lib.escapeShellArg cfg.archivePath} + Service = { + ExecStartPre = '' + ${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p ${ + lib.escapeShellArg cfg.archivePath + }" ''; - in "${archiveScript}/bin/${scriptName}"; - StandardOutput = "journal"; - StandardError = "journal"; - }; - }) cfg.jobs; + ExecStart = + let + scriptName = + "yt-dlp-archive-service-${config.home.username}-${name}"; + jobLevelArgs = lib.escapeShellArgs value.extraArgs; + urls = lib.escapeShellArgs 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; - 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/profiles/dev.nix b/modules/nixos/profiles/dev.nix index d3b3837d..efa23d9a 100644 --- a/modules/nixos/profiles/dev.nix +++ b/modules/nixos/profiles/dev.nix @@ -47,7 +47,7 @@ in { # Also, this config is based from this tip. # https://lists.reproducible-builds.org/pipermail/diffoscope/2016-April/000193.html config.difftool."diffoscope".cmd = '' - "if [ $LOCAL = /dev/null ]; then diffoscope --new-file $REMOTE; else diffoscope $LOCAL $REMOTE; fi" + "if [ $LOCAL = /dev/null ]; then diffoscope --new-file $REMOTE; else diffoscope $LOCAL $REMOTE; fi" ''; config.difftool."diffoscope-html".cmd = '' @@ -87,15 +87,15 @@ in { moreutils # Less is more but more utilities, the merrier. valgrind # Making sure your applications don't pee as much. ] - # 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) + # 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 [ - github-cli # Client for GitHub. - hut # And one for Sourcehut. - ]); + # Enable all of the gud things. + ++ (lib.optionals config.programs.git.enable [ + github-cli # Client for GitHub. + hut # And one for Sourcehut. + ]); systemd.user.services.nix-upgrade-profile = { description = '' diff --git a/modules/nixos/profiles/filesystem.nix b/modules/nixos/profiles/filesystem.nix index c4cc2ed9..114475ff 100644 --- a/modules/nixos/profiles/filesystem.nix +++ b/modules/nixos/profiles/filesystem.nix @@ -2,7 +2,8 @@ let cfg = config.profiles.filesystem; -in { +in +{ options.profiles.filesystem = { archive.enable = lib.mkOption { type = lib.types.bool; diff --git a/modules/nixos/profiles/system.nix b/modules/nixos/profiles/system.nix index 940ec96c..0f0830f7 100644 --- a/modules/nixos/profiles/system.nix +++ b/modules/nixos/profiles/system.nix @@ -217,7 +217,8 @@ in { }; dates = "weekly"; flags = [ - "--update-input" "nixpkgs" + "--update-input" + "nixpkgs" "--commit-lock-file" "--no-write-lock-file" ]; diff --git a/modules/nixos/programs/cardboard-wm.nix b/modules/nixos/programs/cardboard-wm.nix index 4118e34b..c813d3c5 100644 --- a/modules/nixos/programs/cardboard-wm.nix +++ b/modules/nixos/programs/cardboard-wm.nix @@ -6,7 +6,8 @@ let cardboardPackage = cfg.package.overrideAttrs (super: rec { passthru.providedSessions = [ "cardboard" ]; }); -in { +in +{ options.programs.cardboard-wm = { enable = lib.mkEnableOption "Cardboard, a scrollable tiling Wayland compositor"; @@ -23,13 +24,13 @@ in { extraOptions = lib.mkOption { type = with lib.types; listOf str; - default = []; + default = [ ]; description = "Command-line arguments to be passed to Cardboard."; }; extraPackages = lib.mkOption { type = with lib.types; listOf package; - default = []; + default = [ ]; description = '' Extra packages to be installed with this program. ''; diff --git a/modules/nixos/programs/kiwmi.nix b/modules/nixos/programs/kiwmi.nix index a8971bb4..d0e7b642 100644 --- a/modules/nixos/programs/kiwmi.nix +++ b/modules/nixos/programs/kiwmi.nix @@ -4,7 +4,8 @@ let cfg = config.programs.kiwmi; package = cfg.package.override { extraOptions = cfg.extraOptions; }; -in { +in +{ options.programs.kiwmi = { enable = lib.mkEnableOption "Kiwmi, a fully programmable Wayland compositor"; package = lib.mkOption { diff --git a/modules/nixos/programs/pop-launcher.nix b/modules/nixos/programs/pop-launcher.nix index 53698e27..c582362b 100644 --- a/modules/nixos/programs/pop-launcher.nix +++ b/modules/nixos/programs/pop-launcher.nix @@ -14,9 +14,11 @@ let # Some plugins may be packaged busybox-style with multiple plugins in one # binary. - plugins = lib.lists.map (p: p.overrideAttrs (prev: { - dontRewriteSymlinks = true; - })) cfg.plugins; + plugins = lib.lists.map + (p: p.overrideAttrs (prev: { + dontRewriteSymlinks = true; + })) + cfg.plugins; # Plugins and scripts are assumed to be packaged at # `$out/share/pop-launcher`. @@ -58,7 +60,7 @@ in List of packages containing Pop launcher plugins and scripts to be installed as system-wide plugins. ''; - default = []; + default = [ ]; defaultText = "[]"; example = lib.literalExpression '' with pkgs; [ diff --git a/modules/nixos/programs/wezterm.nix b/modules/nixos/programs/wezterm.nix index 4cf90ba6..58b589b9 100644 --- a/modules/nixos/programs/wezterm.nix +++ b/modules/nixos/programs/wezterm.nix @@ -2,7 +2,8 @@ let cfg = config.programs.wezterm; -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 98fa95b8..83bc4289 100644 --- a/modules/nixos/services/archivebox.nix +++ b/modules/nixos/services/archivebox.nix @@ -42,7 +42,8 @@ let persistent = lib.mkEnableOption "service persistence for this job"; }; }; -in { +in +{ options.services.archivebox = { enable = lib.mkEnableOption "Archivebox service"; @@ -96,87 +97,93 @@ in { }; }; - config = let - pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies - (with pkgs; [ chromium nodejs_latest wget curl youtube-dl ])); - in lib.mkIf cfg.enable { - systemd.services = lib.mkMerge [ - (lib.mapAttrs' (name: value: - lib.nameValuePair (jobUnitName name) { - description = - "Archivebox archive group '${name}' for ${cfg.archivePath}"; - after = [ "network.target" ]; - documentation = [ "https://docs.archivebox.io/" ]; - path = with pkgs; - [ ripgrep coreutils ] ++ pkgSet ++ [ config.programs.git.package ]; - preStart = '' - mkdir -p ${lib.escapeShellArg cfg.archivePath} - ''; - script = '' - echo "${lib.concatStringsSep "\n" value.urls}" \ - | archivebox add ${lib.concatStringsSep " " value.extraArgs} - ''; - 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"; - WorkingDirectory = cfg.archivePath; - }; - }) cfg.jobs) + config = + let + pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies + (with pkgs; [ chromium nodejs_latest wget curl youtube-dl ])); + in + lib.mkIf cfg.enable { + systemd.services = lib.mkMerge [ + (lib.mapAttrs' + (name: value: + lib.nameValuePair (jobUnitName name) { + description = + "Archivebox archive group '${name}' for ${cfg.archivePath}"; + after = [ "network.target" ]; + documentation = [ "https://docs.archivebox.io/" ]; + path = with pkgs; + [ ripgrep coreutils ] ++ pkgSet ++ [ config.programs.git.package ]; + preStart = '' + mkdir -p ${lib.escapeShellArg cfg.archivePath} + ''; + script = '' + echo "${lib.concatStringsSep "\n" value.urls}" \ + | archivebox add ${lib.concatStringsSep " " value.extraArgs} + ''; + 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"; + WorkingDirectory = cfg.archivePath; + }; + }) + cfg.jobs) - (lib.mkIf cfg.webserver.enable { - archivebox-server = { - description = "Archivebox server for ${cfg.archivePath}"; - after = [ "network.target" ]; - documentation = [ "https://docs.archivebox.io/" ]; - wantedBy = [ "graphical-session.target" ]; - preStart = '' - mkdir -p ${lib.escapeShellArg cfg.archivePath} - ''; - serviceConfig = { - ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${ + (lib.mkIf cfg.webserver.enable { + archivebox-server = { + description = "Archivebox server for ${cfg.archivePath}"; + after = [ "network.target" ]; + documentation = [ "https://docs.archivebox.io/" ]; + wantedBy = [ "graphical-session.target" ]; + preStart = '' + mkdir -p ${lib.escapeShellArg cfg.archivePath} + ''; + serviceConfig = { + ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${ toString cfg.webserver.port }"; - Restart = "on-failure"; - 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"; - WorkingDirectory = cfg.archivePath; + Restart = "on-failure"; + 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"; + WorkingDirectory = cfg.archivePath; + }; }; - }; - }) - ]; + }) + ]; - systemd.timers = lib.mapAttrs' (name: value: - lib.nameValuePair (jobUnitName name) { - description = - "Archivebox archive group '${name}' for ${cfg.archivePath}"; - after = [ "network.target" ]; - documentation = [ "https://docs.archivebox.io/" ]; - timerConfig = { - Persistent = value.persistent; - OnCalendar = value.startAt; - RandomizedDelaySec = 120; - }; - wantedBy = [ "timers.target" ]; - }) cfg.jobs; - }; + systemd.timers = lib.mapAttrs' + (name: value: + lib.nameValuePair (jobUnitName name) { + description = + "Archivebox archive group '${name}' for ${cfg.archivePath}"; + after = [ "network.target" ]; + documentation = [ "https://docs.archivebox.io/" ]; + timerConfig = { + Persistent = value.persistent; + OnCalendar = value.startAt; + RandomizedDelaySec = 120; + }; + wantedBy = [ "timers.target" ]; + }) + cfg.jobs; + }; } diff --git a/modules/nixos/services/gallery-dl.nix b/modules/nixos/services/gallery-dl.nix index 792d3224..c1aed1ac 100644 --- a/modules/nixos/services/gallery-dl.nix +++ b/modules/nixos/services/gallery-dl.nix @@ -80,7 +80,8 @@ let }; }; }; -in { +in +{ options.services.gallery-dl = { enable = lib.mkEnableOption "archiving services with gallery-dl"; @@ -157,64 +158,70 @@ 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 coreutils ffmpeg cfg.package ]; - preStart = '' - mkdir -p ${lib.escapeShellArg cfg.archivePath} - ''; + 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 coreutils ffmpeg cfg.package ]; + preStart = '' + mkdir -p ${lib.escapeShellArg cfg.archivePath} + ''; - # 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 cfg.extraArgs} ${ - lib.optionalString (cfg.settings != null) - "--config ${settingsFormatFile}" - } ${lib.escapeShellArgs value.extraArgs} ${ - lib.optionalString (value.settings != null) - "--config ${jobLevelSettingsFile}" - } --destination ${lib.escapeShellArg cfg.archivePath} ${ - 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 cfg.extraArgs} ${ + lib.optionalString (cfg.settings != null) + "--config ${settingsFormatFile}" + } ${lib.escapeShellArgs value.extraArgs} ${ + lib.optionalString (value.settings != null) + "--config ${jobLevelSettingsFile}" + } --destination ${lib.escapeShellArg cfg.archivePath} ${ + 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 = value.persistent; - RandomizedDelaySec = "2min"; - }; - }) cfg.jobs; + systemd.timers = lib.mapAttrs' + (name: value: + lib.nameValuePair (jobUnitName name) { + timerConfig = { + Persistent = value.persistent; + RandomizedDelaySec = "2min"; + }; + }) + cfg.jobs; }; } diff --git a/modules/nixos/services/yt-dlp.nix b/modules/nixos/services/yt-dlp.nix index a01740d3..55a45746 100644 --- a/modules/nixos/services/yt-dlp.nix +++ b/modules/nixos/services/yt-dlp.nix @@ -62,7 +62,8 @@ let }; }; }; -in { +in +{ options.services.yt-dlp = { enable = lib.mkEnableOption "archiving service with yt-dlp"; @@ -130,47 +131,52 @@ in { # There's no need to go to the working directory since yt-dlp has the # `--paths` flag. config = lib.mkIf cfg.enable { - systemd.services = lib.mapAttrs' (name: value: let - jobLevelArgs = lib.escapeShellArgs value.extraArgs; - in - lib.nameValuePair (jobUnitName name) { - wantedBy = [ "multi-user.target" ]; - description = "yt-dlp archive job for group '${name}'"; - documentation = [ "man:yt-dlp(1)" ]; - enable = true; - path = [ cfg.package pkgs.coreutils ]; - preStart = '' - mkdir -p ${lib.escapeShellArg cfg.archivePath} - ''; - script = '' - yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \ - ${lib.escapeShellArgs value.urls} --paths ${lib.escapeShellArg cfg.archivePath} - ''; - startAt = value.startAt; - serviceConfig = { - LockPersonality = true; - NoNewPrivileges = true; - PrivateTmp = true; - PrivateUsers = true; - PrivateDevices = true; - ProtectControlGroups = true; - ProtectClock = true; - ProtectKernelLogs = true; - ProtectKernelModules = true; - ProtectKernelTunables = true; - StandardOutput = "journal"; - StandardError = "journal"; - SystemCallFilter = "@system-service"; - SystemCallErrorNumber = "EPERM"; - }; - }) cfg.jobs; + systemd.services = lib.mapAttrs' + (name: value: + let + jobLevelArgs = lib.escapeShellArgs value.extraArgs; + in + lib.nameValuePair (jobUnitName name) { + wantedBy = [ "multi-user.target" ]; + description = "yt-dlp archive job for group '${name}'"; + documentation = [ "man:yt-dlp(1)" ]; + enable = true; + path = [ cfg.package pkgs.coreutils ]; + preStart = '' + mkdir -p ${lib.escapeShellArg cfg.archivePath} + ''; + script = '' + yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \ + ${lib.escapeShellArgs value.urls} --paths ${lib.escapeShellArg cfg.archivePath} + ''; + startAt = value.startAt; + serviceConfig = { + LockPersonality = true; + NoNewPrivileges = true; + PrivateTmp = true; + PrivateUsers = true; + PrivateDevices = true; + ProtectControlGroups = true; + ProtectClock = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + StandardOutput = "journal"; + StandardError = "journal"; + SystemCallFilter = "@system-service"; + SystemCallErrorNumber = "EPERM"; + }; + }) + cfg.jobs; - systemd.timers = lib.mapAttrs' (name: value: - lib.nameValuePair (jobUnitName name) { - timerConfig = { - Persistent = value.persistent; - RandomizedDelaySec = "2min"; - }; - }) cfg.jobs; + systemd.timers = lib.mapAttrs' + (name: value: + lib.nameValuePair (jobUnitName name) { + timerConfig = { + Persistent = value.persistent; + RandomizedDelaySec = "2min"; + }; + }) + cfg.jobs; }; } diff --git a/modules/nixos/workflows/a-happy-gnome/default.nix b/modules/nixos/workflows/a-happy-gnome/default.nix index cf88fb99..212b6d9e 100644 --- a/modules/nixos/workflows/a-happy-gnome/default.nix +++ b/modules/nixos/workflows/a-happy-gnome/default.nix @@ -13,7 +13,7 @@ let }; # We're combining all of the custom dconf database into a package to be installed. - dconfConfig = pkgs.runCommand "install-a-happy-gnome-dconf-keyfiles" {} '' + dconfConfig = pkgs.runCommand "install-a-happy-gnome-dconf-keyfiles" { } '' install -Dm644 ${./config/dconf}/*.conf -t $out/etc/dconf/db/${name}-conf.d install -Dm644 ${enabledExtensions} $out/etc/dconf/db/${name}-conf.d/90-enabled-extensions.conf ''; @@ -132,8 +132,8 @@ in profiles.user = pkgs.writeTextFile { name = "a-happy-gnome"; text = '' - user-db:user - system-db:${name}-conf + user-db:user + system-db:${name}-conf ''; }; }; diff --git a/modules/nixos/workflows/knome/default.nix b/modules/nixos/workflows/knome/default.nix index e811af8f..a08ba1ac 100644 --- a/modules/nixos/workflows/knome/default.nix +++ b/modules/nixos/workflows/knome/default.nix @@ -2,7 +2,8 @@ let cfg = config.workflows.workflows.knome; -in { +in +{ options.workflows.workflows.knome.enable = lib.mkEnableOption "KNOME, an attempt to bring as much GNOME to KDE Plasma"; config = lib.mkIf cfg.enable { diff --git a/pkgs/software-heritage/default.nix b/pkgs/software-heritage/default.nix index b3ef1bc8..93e6b032 100644 --- a/pkgs/software-heritage/default.nix +++ b/pkgs/software-heritage/default.nix @@ -1,8 +1,10 @@ { lib, callPackage, newScope, python3Packages, ... }: -lib.fix' (self: let +lib.fix' (self: +let callPackage = newScope self; -in lib.recurseIntoAttrs { +in +lib.recurseIntoAttrs { attrs-strict = callPackage ./attrs-strict.nix { inherit python3Packages; }; aiohttp-utils = callPackage ./aiohttp-utils.nix { inherit python3Packages; }; diff --git a/pkgs/tic-80/default.nix b/pkgs/tic-80/default.nix index fed8c0e5..31cb16ab 100644 --- a/pkgs/tic-80/default.nix +++ b/pkgs/tic-80/default.nix @@ -73,11 +73,11 @@ stdenv.mkDerivation rec { valgrind sndio ] ++ lib.optional pulseaudioSupport libpulseaudio - ++ lib.optional jackSupport jack2 ++ lib.optional esoundSupport espeak - ++ lib.optionals (stdenv.isLinux && waylandSupport) [ - wayland - libxkbcommon - ]; + ++ lib.optional jackSupport jack2 ++ lib.optional esoundSupport espeak + ++ lib.optionals (stdenv.isLinux && waylandSupport) [ + wayland + libxkbcommon + ]; # TODO: Replace SOKOL-built version with SDL. cmakeFlags = [ "-DBUILD_PRO=ON" ]; diff --git a/templates/basic-overlay-flake/flake.nix b/templates/basic-overlay-flake/flake.nix index c07b13ad..265bcdf4 100644 --- a/templates/basic-overlay-flake/flake.nix +++ b/templates/basic-overlay-flake/flake.nix @@ -27,6 +27,6 @@ }) // { overlays.default = final: prev: import ./pkgs { pkgs = prev; }; - nixosModules = {}; + nixosModules = { }; }; } diff --git a/users/home-manager/foo-dogsquared/default.nix b/users/home-manager/foo-dogsquared/default.nix index 73fa73eb..0c7e8399 100644 --- a/users/home-manager/foo-dogsquared/default.nix +++ b/users/home-manager/foo-dogsquared/default.nix @@ -24,7 +24,8 @@ let musicDir = config.xdg.userDirs.music; playlistsDir = "${musicDir}/playlists"; -in { +in +{ home.packages = with pkgs; [ songrec vscodium-fhs