diff --git a/.github/workflows/github_pages.yml b/.github/workflows/github_pages.yml index 9f49d49a8..4e10f9ccb 100644 --- a/.github/workflows/github_pages.yml +++ b/.github/workflows/github_pages.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v27 + - uses: cachix/install-nix-action@v30 with: nix_path: nixpkgs=channel:nixos-unstable - uses: cachix/cachix-action@v15 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99a2f5a1a..ff67b6760 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v27 + - uses: cachix/install-nix-action@v30 with: nix_path: nixpkgs=channel:nixos-unstable - run: | diff --git a/.github/workflows/update-flake.yml b/.github/workflows/update-flake.yml index ba9b5f818..9b0e4b443 100644 --- a/.github/workflows/update-flake.yml +++ b/.github/workflows/update-flake.yml @@ -12,7 +12,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - name: Install Nix - uses: cachix/install-nix-action@v27 + uses: cachix/install-nix-action@v30 - name: Update flake.lock uses: DeterminateSystems/update-flake-lock@v24 with: diff --git a/docs/home-manager-manual.nix b/docs/home-manager-manual.nix index 23b2d1e65..f87803962 100644 --- a/docs/home-manager-manual.nix +++ b/docs/home-manager-manual.nix @@ -59,5 +59,7 @@ in stdenv.mkDerivation { echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products ''; + passthru = { inherit home-manager-options; }; + meta = { maintainers = [ lib.maintainers.considerate ]; }; } diff --git a/flake.lock b/flake.lock index 557a2e855..76920c875 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1726937504, - "narHash": "sha256-bvGoiQBvponpZh8ClUcmJ6QnsNKw0EMrCQJARK3bI1c=", + "lastModified": 1728241625, + "narHash": "sha256-yumd4fBc/hi8a9QgA9IT8vlQuLZ2oqhkJXHPKxH/tRw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9357f4f23713673f310988025d9dc261c20e70c6", + "rev": "c31898adf5a8ed202ce5bea9f347b1c6871f32d1", "type": "github" }, "original": { diff --git a/home-manager/po/hi.po b/home-manager/po/hi.po index 43d873123..3921eff11 100644 --- a/home-manager/po/hi.po +++ b/home-manager/po/hi.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: Home Manager\n" "Report-Msgid-Bugs-To: https://github.com/nix-community/home-manager/issues\n" "POT-Creation-Date: 2024-04-17 23:19+0200\n" -"PO-Revision-Date: 2024-09-13 03:09+0000\n" -"Last-Translator: Jay Thomas \n" +"PO-Revision-Date: 2024-10-09 14:31+0000\n" +"Last-Translator: Utkarsh Sharma \n" "Language-Team: Hindi \n" "Language: hi\n" @@ -22,11 +22,11 @@ msgstr "" #. translators: For example: "home-manager: missing argument for --cores" #: home-manager/home-manager:16 msgid "%s: missing argument for %s" -msgstr "" +msgstr "%s: ‌%s के लिए कोई आर्ग्यूमेंट नहीं दिया" #: home-manager/home-manager:64 msgid "No configuration file found at %s" -msgstr "" +msgstr "%s में कोई कन्फि़गरेशन फाइल नहीं मिली" #. translators: The first '%s' specifier will be replaced by either #. 'home.nix' or 'flake.nix'. diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index 70f480d06..501917ffb 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -7,6 +7,12 @@ # [1] https://github.com/NixOS/nixpkgs/blob/fca0d6e093c82b31103dc0dacc48da2a9b06e24b/maintainers/maintainer-list.nix#LC1 { + aabccd021 = { + name = "Muhamad Abdurahman"; + email = "aabccd021@gmail.com"; + github = "aabccd021"; + githubId = 33031950; + }; abayomi185 = { name = "Yomi"; email = "yomi+nix@yomitosh.com"; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index f8786de2f..732c92478 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1748,6 +1748,28 @@ in { add `-w` to your assignment of `services.swayidle.extraArgs`. ''; } + + { + time = "2024-10-09T06:16:23+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.snixembed'. + + snixembed proxies StatusNotifierItems as XEmbedded systemtray-spec + icons. This is useful for some tools in some environments, e.g., Safe + Eyes in i3, lxde or mate. + ''; + } + + { + time = "2024-10-11T08:23:19+00:00"; + message = '' + A new module is available: 'programs.vifm'. + + Vifm is a curses based Vim-like file manager extended with some useful + ideas from mutt. + ''; + } ]; }; } diff --git a/modules/misc/xdg-mime.nix b/modules/misc/xdg-mime.nix index 09f62aaff..78b569fa5 100644 --- a/modules/misc/xdg-mime.nix +++ b/modules/misc/xdg-mime.nix @@ -5,33 +5,50 @@ with lib; let cfg = config.xdg.mime; + inherit (lib) getExe getExe'; in { options = { - xdg.mime.enable = mkOption { - type = types.bool; - default = pkgs.stdenv.hostPlatform.isLinux; - defaultText = - literalExpression "true if host platform is Linux, false otherwise"; - description = '' - Whether to install programs and files to support the - XDG Shared MIME-info specification and XDG MIME Applications - specification at - - and - , - respectively. - ''; + xdg.mime = { + enable = mkOption { + type = types.bool; + default = pkgs.stdenv.hostPlatform.isLinux; + defaultText = + literalExpression "true if host platform is Linux, false otherwise"; + description = '' + Whether to install programs and files to support the + XDG Shared MIME-info specification and XDG MIME Applications + specification at + + and + , + respectively. + ''; + }; + + sharedMimeInfoPackage = mkOption { + type = types.package; + default = pkgs.shared-mime-info; + defaultText = literalExpression "pkgs.shared-mime-info"; + description = "The package to use when running update-mime-database."; + }; + + desktopFileUtilsPackage = mkOption { + type = types.package; + default = pkgs.desktop-file-utils; + defaultText = literalExpression "pkgs.desktop-file-utils"; + description = + "The package to use when running update-desktop-database."; + }; }; }; - - config = mkIf config.xdg.mime.enable { + config = mkIf cfg.enable { assertions = [ (hm.assertions.assertPlatform "xdg.mime" pkgs platforms.linux) ]; home.packages = [ # Explicitly install package to provide basic mime types. - pkgs.shared-mime-info + cfg.sharedMimeInfoPackage # Make sure the target directories will be real directories. (pkgs.runCommandLocal "dummy-xdg-mime-dirs1" { } '' @@ -46,12 +63,12 @@ in { if [[ -w $out/share/mime && -w $out/share/mime/packages && -d $out/share/mime/packages ]]; then XDG_DATA_DIRS=$out/share \ PKGSYSTEM_ENABLE_FSYNC=0 \ - ${pkgs.buildPackages.shared-mime-info}/bin/update-mime-database \ + ${getExe cfg.sharedMimeInfoPackage} \ -V $out/share/mime > /dev/null fi if [[ -w $out/share/applications ]]; then - ${pkgs.buildPackages.desktop-file-utils}/bin/update-desktop-database \ + ${getExe' cfg.desktopFileUtilsPackage "update-desktop-database"} \ $out/share/applications fi ''; diff --git a/modules/misc/xdg.nix b/modules/misc/xdg.nix index a47a33f56..b916e88fb 100644 --- a/modules/misc/xdg.nix +++ b/modules/misc/xdg.nix @@ -30,6 +30,8 @@ in { apply = toString; description = '' Absolute path to directory holding application caches. + + Sets `XDG_CACHE_HOME` for the user if `xdg.enable` is set `true`. ''; }; @@ -48,6 +50,8 @@ in { apply = toString; description = '' Absolute path to directory holding application configurations. + + Sets `XDG_CONFIG_HOME` for the user if `xdg.enable` is set `true`. ''; }; @@ -67,6 +71,8 @@ in { apply = toString; description = '' Absolute path to directory holding application data. + + Sets `XDG_DATA_HOME` for the user if `xdg.enable` is set `true`. ''; }; @@ -86,6 +92,8 @@ in { apply = toString; description = '' Absolute path to directory holding application states. + + Sets `XDG_STATE_HOME` for the user if `xdg.enable` is set `true`. ''; }; }; diff --git a/modules/modules.nix b/modules/modules.nix index ed2e177f2..72f4adaae 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -241,8 +241,9 @@ let ./programs/translate-shell.nix ./programs/urxvt.nix ./programs/vdirsyncer.nix - ./programs/vim.nix + ./programs/vifm.nix ./programs/vim-vint.nix + ./programs/vim.nix ./programs/vscode.nix ./programs/vscode/haskell.nix ./programs/pywal.nix @@ -361,6 +362,7 @@ let ./services/screen-locker.nix ./services/sctd.nix ./services/signaturepdf.nix + ./services/snixembed.nix ./services/spotifyd.nix ./services/ssh-agent.nix ./services/stalonetray.nix diff --git a/modules/po/hi.po b/modules/po/hi.po index 02a7f8528..80781aba5 100644 --- a/modules/po/hi.po +++ b/modules/po/hi.po @@ -8,13 +8,16 @@ msgstr "" "Project-Id-Version: Home Manager Modules\n" "Report-Msgid-Bugs-To: https://github.com/nix-community/home-manager/issues\n" "POT-Creation-Date: 2024-04-17 23:19+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" +"PO-Revision-Date: 2024-10-09 14:31+0000\n" +"Last-Translator: Utkarsh Sharma \n" +"Language-Team: Hindi \n" "Language: hi\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 5.8-dev\n" #: modules/files.nix:191 msgid "Creating home file links in %s" @@ -22,7 +25,7 @@ msgstr "" #: modules/files.nix:204 msgid "Cleaning up orphan links from %s" -msgstr "" +msgstr "%s से ऑर्फे़न लिंक्स मिटाई जा रही है" #: modules/files.nix:220 msgid "Creating profile generation %s" diff --git a/modules/programs/borgmatic.nix b/modules/programs/borgmatic.nix index ecc6f5cf3..97a1d54ce 100644 --- a/modules/programs/borgmatic.nix +++ b/modules/programs/borgmatic.nix @@ -272,10 +272,7 @@ in { }; config = mkIf cfg.enable { - assertions = [ - (lib.hm.assertions.assertPlatform "programs.borgmatic" pkgs - lib.platforms.linux) - ] ++ (mapAttrsToList (backup: opts: { + assertions = (mapAttrsToList (backup: opts: { assertion = opts.location.sourceDirectories == null || opts.location.patterns == null; message = '' diff --git a/modules/programs/git.nix b/modules/programs/git.nix index 07d01ab9d..dfdac2d4b 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -214,6 +214,41 @@ in { }; }; + maintenance = { + enable = mkEnableOption "" // { + description = '' + Enable the automatic {command}`git maintenance`. + + See . + ''; + }; + + repositories = mkOption { + type = with types; listOf str; + default = [ ]; + description = '' + Repositories on which {command}`git maintenance` should run. + + Should be a list of absolute paths. + ''; + }; + + timers = mkOption { + type = types.attrsOf types.str; + default = { + hourly = "*-*-* 1..23:53:00"; + daily = "Tue..Sun *-*-* 0:53:00"; + weekly = "Mon 0:53:00"; + }; + description = '' + Systemd timers to create for scheduled {command}`git maintenance`. + + Key is passed to `--schedule` argument in {command}`git maintenance run` + and value is passed to `Timer.OnCalendar` in `systemd.user.timers`. + ''; + }; + }; + diff-highlight = { enable = mkEnableOption "" // { description = '' @@ -501,6 +536,48 @@ in { }; }) + (mkIf cfg.maintenance.enable { + programs.git.iniContent.maintenance.repo = cfg.maintenance.repositories; + + systemd.user.services."git-maintenance@" = { + Unit = { + Description = "Optimize Git repositories data"; + Documentation = [ "man:git-maintenance(1)" ]; + }; + + Service = { + Type = "oneshot"; + ExecStart = let exe = lib.getExe cfg.package; + in '' + "${exe}" --exec-path="${exe}" for-each-repo --config=maintenance.repo maintenance run --schedule=%i + ''; + LockPersonality = "yes"; + MemoryDenyWriteExecute = "yes"; + NoNewPrivileges = "yes"; + RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6 AF_VSOCK"; + RestrictNamespaces = "yes"; + RestrictRealtime = "yes"; + RestrictSUIDSGID = "yes"; + SystemCallArchitectures = "native"; + SystemCallFilter = "@system-service"; + }; + }; + + systemd.user.timers = let + toSystemdTimer = name: time: + lib.attrsets.nameValuePair "git-maintenance@${name}" { + Unit.Description = "Optimize Git repositories data"; + + Timer = { + OnCalendar = time; + Persistent = true; + }; + + Install.WantedBy = [ "timers.target" ]; + }; + in lib.attrsets.mapAttrs' toSystemdTimer cfg.maintenance.timers; + }) + (mkIf cfg.diff-highlight.enable { programs.git.iniContent = let dhCommand = diff --git a/modules/programs/kitty.nix b/modules/programs/kitty.nix index e9594ec12..9854fe69c 100644 --- a/modules/programs/kitty.nix +++ b/modules/programs/kitty.nix @@ -5,7 +5,7 @@ with lib; let cfg = config.programs.kitty; - eitherStrBoolInt = with types; either str (either bool int); + settingsValueType = with types; oneOf [ str bool int float ]; optionalPackage = opt: optional (opt != null && opt.package != null) opt.package; @@ -102,7 +102,7 @@ in { }; settings = mkOption { - type = types.attrsOf eitherStrBoolInt; + type = types.attrsOf settingsValueType; default = { }; example = literalExpression '' { diff --git a/modules/programs/vifm.nix b/modules/programs/vifm.nix new file mode 100644 index 000000000..2bf31d52d --- /dev/null +++ b/modules/programs/vifm.nix @@ -0,0 +1,33 @@ +{ config, lib, pkgs, ... }: + +let + + inherit (lib) mkIf mkOption types; + + cfg = config.programs.vifm; + +in { + meta.maintainers = [ lib.hm.maintainers.aabccd021 ]; + + options.programs.vifm = { + enable = lib.mkEnableOption "vifm, a Vim-like file manager"; + + package = lib.mkPackageOption pkgs "vifm" { }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + example = "mark h ~/"; + description = '' + Extra lines added to the {file}`$XDG_CONFIG_HOME/vifm/vifmrc` file. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + xdg.configFile."vifm/vifmrc" = + mkIf (cfg.extraConfig != "") { text = cfg.extraConfig; }; + }; +} diff --git a/modules/programs/zathura.nix b/modules/programs/zathura.nix index ba34af590..3e41256d3 100644 --- a/modules/programs/zathura.nix +++ b/modules/programs/zathura.nix @@ -31,7 +31,7 @@ in { options = mkOption { default = { }; - type = with types; attrsOf (either str (either bool int)); + type = with types; attrsOf (oneOf [ str bool int float ]); description = '' Add {option}`:set` command options to zathura and make them permanent. See diff --git a/modules/services/megasync.nix b/modules/services/megasync.nix index c519ba51f..03eab490a 100644 --- a/modules/services/megasync.nix +++ b/modules/services/megasync.nix @@ -28,7 +28,7 @@ in { systemd.user.services.megasync = { Unit = { Description = "megasync"; - After = [ "graphical-session-pre.target" ]; + After = [ "graphical-session.target" ]; PartOf = [ "graphical-session.target" ]; }; diff --git a/modules/services/pass-secret-service.nix b/modules/services/pass-secret-service.nix index db494337e..c6ea59918 100644 --- a/modules/services/pass-secret-service.nix +++ b/modules/services/pass-secret-service.nix @@ -58,6 +58,7 @@ in { optionalString (cfg.storePath != null) "--path ${cfg.storePath}" }"; BusName = busName; + Environment = [ "GNUPGHOME=${config.programs.gpg.homedir}" ]; }; Install.WantedBy = [ "default.target" ]; diff --git a/modules/services/snixembed.nix b/modules/services/snixembed.nix new file mode 100644 index 000000000..a470836b0 --- /dev/null +++ b/modules/services/snixembed.nix @@ -0,0 +1,50 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.services.snixembed; +in { + meta.maintainers = [ maintainers.DamienCassou ]; + + options = { + services.snixembed = { + enable = mkEnableOption + "snixembed: proxy StatusNotifierItems as XEmbedded systemtray-spec icons"; + + package = mkPackageOption pkgs "snixembed" { }; + + beforeUnits = mkOption { + type = with types; listOf str; + default = [ ]; + example = [ "safeeyes.service" ]; + description = '' + List of other units that should be started after snixembed. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "services.snixembed" pkgs platforms.linux) + ]; + + systemd.user.services.snixembed = { + Install.WantedBy = [ "graphical-session.target" ]; + + Unit = { + Description = "snixembed"; + PartOf = [ "graphical-session.target" ]; + StartLimitIntervalSec = 100; + StartLimitBurst = 10; + Before = cfg.beforeUnits; + }; + + Service = { + ExecStart = getExe pkgs.snixembed; + Restart = "on-failure"; + RestartSec = 3; + }; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 2008014b7..83ed42a70 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -60,6 +60,7 @@ in import nmtSrc { ./modules/programs/bacon ./modules/programs/bash ./modules/programs/bat + ./modules/programs/borgmatic ./modules/programs/bottom ./modules/programs/broot ./modules/programs/browserpass @@ -154,6 +155,7 @@ in import nmtSrc { ./modules/programs/tmux ./modules/programs/topgrade ./modules/programs/translate-shell + ./modules/programs/vifm ./modules/programs/vim-vint ./modules/programs/vscode ./modules/programs/watson @@ -189,7 +191,6 @@ in import nmtSrc { ./modules/programs/awscli ./modules/programs/beets # One test relies on services.mpd ./modules/programs/bemenu - ./modules/programs/borgmatic ./modules/programs/boxxy ./modules/programs/firefox/firefox.nix ./modules/programs/foot @@ -270,6 +271,7 @@ in import nmtSrc { ./modules/services/remmina ./modules/services/screen-locker ./modules/services/signaturepdf + ./modules/services/snixembed ./modules/services/swayidle ./modules/services/swaync ./modules/services/swayosd diff --git a/tests/modules/misc/xdg/default.nix b/tests/modules/misc/xdg/default.nix index bc2f9a9df..87f74e22f 100644 --- a/tests/modules/misc/xdg/default.nix +++ b/tests/modules/misc/xdg/default.nix @@ -6,4 +6,7 @@ xdg-default-locations = ./default-locations.nix; xdg-user-dirs-null = ./user-dirs-null.nix; xdg-portal = ./portal.nix; + xdg-mime = ./mime.nix; + xdg-mime-disabled = ./mime-disabled.nix; + xdg-mime-package = ./mime-packages.nix; } diff --git a/tests/modules/misc/xdg/mime-disabled.nix b/tests/modules/misc/xdg/mime-disabled.nix new file mode 100644 index 000000000..a3df63091 --- /dev/null +++ b/tests/modules/misc/xdg/mime-disabled.nix @@ -0,0 +1,10 @@ +{ ... }: { + config = { + xdg.mime.enable = false; + nmt.script = '' + # assert that neither application is run + assertPathNotExists home-path/share/applications/mimeinfo.cache + assertPathNotExists home-path/share/applications/mime + ''; + }; +} diff --git a/tests/modules/misc/xdg/mime-expected.cache b/tests/modules/misc/xdg/mime-expected.cache new file mode 100644 index 000000000..6907f8f88 --- /dev/null +++ b/tests/modules/misc/xdg/mime-expected.cache @@ -0,0 +1,3 @@ +[MIME Cache] +text/html=mime-test.desktop; +text/xml=mime-test.desktop; diff --git a/tests/modules/misc/xdg/mime-packages.nix b/tests/modules/misc/xdg/mime-packages.nix new file mode 100644 index 000000000..0eaaddcec --- /dev/null +++ b/tests/modules/misc/xdg/mime-packages.nix @@ -0,0 +1,38 @@ +{ config, ... }: +let inherit (config.lib.test) mkStubPackage; +in { + config = { + xdg.mime.enable = true; + xdg.mime.sharedMimeInfoPackage = mkStubPackage { + name = "update-mime-database"; + buildScript = '' + mkdir -p $out/bin + echo '#!/bin/sh' > $out/bin/update-mime-database + echo 'mkdir -p $out/share/mime && touch $out/share/mime/mime.cache' >> $out/bin/update-mime-database + chmod +x $out/bin/update-mime-database + ''; + }; + xdg.mime.desktopFileUtilsPackage = mkStubPackage { + name = "desktop-file-utils"; + buildScript = '' + mkdir -p $out/bin + echo '#!/bin/sh' > $out/bin/update-desktop-database + echo 'mkdir -p $out/share/applications/ && ln -s ${ + ./mime-expected.cache + } $out/share/applications/mimeinfo.cache' >> $out/bin/update-desktop-database + chmod +x $out/bin/update-desktop-database + ''; + }; + nmt.script = '' + assertFileExists home-path/share/applications/mimeinfo.cache # Check that update-desktop-database created file + # Check that update-desktop-database file matches expected + assertFileContent \ + home-path/share/applications/mimeinfo.cache \ + ${./mime-expected.cache} + + assertDirectoryExists home-path/share/mime # Check that update-mime-database created directory + assertFileExists home-path/share/mime/mime.cache # Check that update-mime-database created file + + ''; + }; +} diff --git a/tests/modules/misc/xdg/mime.nix b/tests/modules/misc/xdg/mime.nix new file mode 100644 index 000000000..90d21d567 --- /dev/null +++ b/tests/modules/misc/xdg/mime.nix @@ -0,0 +1,24 @@ +{ ... }: { + config = { + xdg.mime.enable = true; + xdg.desktopEntries = { + mime-test = { # mime info test + name = "mime-test"; + mimeType = [ "text/html" "text/xml" ]; + }; + + }; + + nmt.script = '' + assertFileExists home-path/share/applications/mimeinfo.cache # Check that update-desktop-database created file + # Check that update-desktop-database file matches expected + assertFileContent \ + home-path/share/applications/mimeinfo.cache \ + ${./mime-expected.cache} + + assertDirectoryExists home-path/share/mime # Check that update-mime-database created directory + assertDirectoryNotEmpty home-path/share/mime # Check that update-mime-database created files + + ''; + }; +} diff --git a/tests/modules/programs/firefox/firefox.nix b/tests/modules/programs/firefox/firefox.nix index 6598d6ec2..6d92a5f49 100644 --- a/tests/modules/programs/firefox/firefox.nix +++ b/tests/modules/programs/firefox/firefox.nix @@ -1,11 +1,16 @@ let name = "firefox"; in builtins.mapAttrs (test: module: import module [ "programs" name ]) { - "${name}-profile-settings" = ./profile-settings.nix; - "${name}-state-version-19_09" = ./state-version-19_09.nix; "${name}-deprecated-native-messenger" = ./deprecated-native-messenger.nix; - "${name}-duplicate-profile-ids" = ./duplicate-profile-ids.nix; - "${name}-duplicate-container-ids" = ./duplicate-container-ids.nix; - "${name}-container-id-out-of-range" = ./container-id-out-of-range.nix; "${name}-policies" = ./policies.nix; + "${name}-profiles-bookmarks" = ./profiles/bookmarks; + "${name}-profiles-containers" = ./profiles/containers; + "${name}-profiles-containers-duplicate-ids" = + ./profiles/containers/duplicate-ids.nix; + "${name}-profiles-containers-id-out-of-range" = + ./profiles/containers/id-out-of-range.nix; + "${name}-profiles-duplicate-ids" = ./profiles/duplicate-ids.nix; + "${name}-profiles-search" = ./profiles/search; + "${name}-profiles-settings" = ./profiles/settings; + "${name}-state-version-19_09" = ./state-version-19_09.nix; } diff --git a/tests/modules/programs/firefox/profile-settings.nix b/tests/modules/programs/firefox/profile-settings.nix deleted file mode 100644 index d7776eb4f..000000000 --- a/tests/modules/programs/firefox/profile-settings.nix +++ /dev/null @@ -1,215 +0,0 @@ -modulePath: -{ config, lib, pkgs, ... }: - -with lib; - -let - - cfg = getAttrFromPath modulePath config; - - firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath; - -in { - imports = [ firefoxMockOverlay ]; - - config = mkIf config.test.enableBig (setAttrByPath modulePath { - enable = true; - profiles.basic.isDefault = true; - - profiles.test = { - id = 1; - settings = { - "general.smoothScroll" = false; - "browser.newtabpage.pinned" = [{ - title = "NixOS"; - url = "https://nixos.org"; - }]; - }; - }; - - profiles.bookmarks = { - id = 2; - settings = { "general.smoothScroll" = false; }; - bookmarks = [ - { - toolbar = true; - bookmarks = [{ - name = "Home Manager"; - url = "https://wiki.nixos.org/wiki/Home_Manager"; - }]; - } - { - name = "wikipedia"; - tags = [ "wiki" ]; - keyword = "wiki"; - url = "https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go"; - } - { - name = "kernel.org"; - url = "https://www.kernel.org"; - } - { - name = "Nix sites"; - bookmarks = [ - { - name = "homepage"; - url = "https://nixos.org/"; - } - { - name = "wiki"; - tags = [ "wiki" "nix" ]; - url = "https://wiki.nixos.org/"; - } - { - name = "Nix sites"; - bookmarks = [ - { - name = "homepage"; - url = "https://nixos.org/"; - } - { - name = "wiki"; - url = "https://wiki.nixos.org/"; - } - ]; - } - ]; - } - ]; - }; - - profiles.search = { - id = 3; - search = { - force = true; - default = "Google"; - privateDefault = "DuckDuckGo"; - order = [ "Nix Packages" "NixOS Wiki" ]; - engines = { - "Nix Packages" = { - urls = [{ - template = "https://search.nixos.org/packages"; - params = [ - { - name = "type"; - value = "packages"; - } - { - name = "query"; - value = "{searchTerms}"; - } - ]; - }]; - - icon = - "/run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; - - definedAliases = [ "@np" ]; - }; - - "NixOS Wiki" = { - urls = [{ - template = - "https://wiki.nixos.org/index.php?search={searchTerms}"; - }]; - iconUpdateURL = "https://wiki.nixos.org/favicon.png"; - updateInterval = 24 * 60 * 60 * 1000; - definedAliases = [ "@nw" ]; - }; - - "Bing".metaData.hidden = true; - "Google".metaData.alias = "@g"; - }; - }; - }; - - profiles.searchWithoutDefault = { - id = 4; - search = { - force = true; - order = [ "Google" "Nix Packages" ]; - engines = { - "Nix Packages" = { - urls = [{ - template = "https://search.nixos.org/packages"; - params = [ - { - name = "type"; - value = "packages"; - } - { - name = "query"; - value = "{searchTerms}"; - } - ]; - }]; - - definedAliases = [ "@np" ]; - }; - }; - }; - }; - - profiles.containers = { - id = 5; - containers = { - "shopping" = { - id = 6; - icon = "circle"; - color = "yellow"; - }; - }; - }; - } // { - - nmt.script = '' - assertFileRegex \ - home-path/bin/${cfg.wrappedPackageName} \ - MOZ_APP_LAUNCHER - - assertDirectoryExists home-files/${cfg.configPath}/basic - - assertFileContent \ - home-files/${cfg.configPath}/test/user.js \ - ${./profile-settings-expected-user.js} - - assertFileContent \ - home-files/${cfg.configPath}/containers/containers.json \ - ${./profile-settings-expected-containers.json} - - bookmarksUserJs=$(normalizeStorePaths \ - home-files/${cfg.configPath}/bookmarks/user.js) - - assertFileContent \ - $bookmarksUserJs \ - ${./profile-settings-expected-bookmarks-user.js} - - bookmarksFile="$(sed -n \ - '/browser.bookmarks.file/ {s|^.*\(/nix/store[^"]*\).*|\1|;p}' \ - $TESTED/home-files/${cfg.configPath}/bookmarks/user.js)" - - assertFileContent \ - $bookmarksFile \ - ${./profile-settings-expected-bookmarks.html} - - function assertFirefoxSearchContent() { - compressedSearch=$(normalizeStorePaths "$1") - - decompressedSearch=$(dirname $compressedSearch)/search.json - ${pkgs.mozlz4a}/bin/mozlz4a -d "$compressedSearch" >(${pkgs.jq}/bin/jq . > "$decompressedSearch") - - assertFileContent \ - $decompressedSearch \ - "$2" - } - - assertFirefoxSearchContent \ - home-files/${cfg.configPath}/search/search.json.mozlz4 \ - ${./profile-settings-expected-search.json} - - assertFirefoxSearchContent \ - home-files/${cfg.configPath}/searchWithoutDefault/search.json.mozlz4 \ - ${./profile-settings-expected-search-without-default.json} - ''; - }); -} diff --git a/tests/modules/programs/firefox/profiles/bookmarks/default.nix b/tests/modules/programs/firefox/profiles/bookmarks/default.nix new file mode 100644 index 000000000..7bf508ab0 --- /dev/null +++ b/tests/modules/programs/firefox/profiles/bookmarks/default.nix @@ -0,0 +1,84 @@ +modulePath: +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = getAttrFromPath modulePath config; + + firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath; + +in { + imports = [ firefoxMockOverlay ]; + + config = mkIf config.test.enableBig (setAttrByPath modulePath { + enable = true; + profiles.bookmarks = { + settings = { "general.smoothScroll" = false; }; + bookmarks = [ + { + toolbar = true; + bookmarks = [{ + name = "Home Manager"; + url = "https://wiki.nixos.org/wiki/Home_Manager"; + }]; + } + { + name = "wikipedia"; + tags = [ "wiki" ]; + keyword = "wiki"; + url = "https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go"; + } + { + name = "kernel.org"; + url = "https://www.kernel.org"; + } + { + name = "Nix sites"; + bookmarks = [ + { + name = "homepage"; + url = "https://nixos.org/"; + } + { + name = "wiki"; + tags = [ "wiki" "nix" ]; + url = "https://wiki.nixos.org/"; + } + { + name = "Nix sites"; + bookmarks = [ + { + name = "homepage"; + url = "https://nixos.org/"; + } + { + name = "wiki"; + url = "https://wiki.nixos.org/"; + } + ]; + } + ]; + } + ]; + }; + } // { + nmt.script = '' + bookmarksUserJs=$(normalizeStorePaths \ + home-files/${cfg.configPath}/bookmarks/user.js) + + assertFileContent \ + $bookmarksUserJs \ + ${./expected-bookmarks-user.js} + + bookmarksFile="$(sed -n \ + '/browser.bookmarks.file/ {s|^.*\(/nix/store[^"]*\).*|\1|;p}' \ + $TESTED/home-files/${cfg.configPath}/bookmarks/user.js)" + + assertFileContent \ + $bookmarksFile \ + ${./expected-bookmarks.html} + ''; + }); +} diff --git a/tests/modules/programs/firefox/profile-settings-expected-bookmarks-user.js b/tests/modules/programs/firefox/profiles/bookmarks/expected-bookmarks-user.js similarity index 100% rename from tests/modules/programs/firefox/profile-settings-expected-bookmarks-user.js rename to tests/modules/programs/firefox/profiles/bookmarks/expected-bookmarks-user.js diff --git a/tests/modules/programs/firefox/profile-settings-expected-bookmarks.html b/tests/modules/programs/firefox/profiles/bookmarks/expected-bookmarks.html similarity index 100% rename from tests/modules/programs/firefox/profile-settings-expected-bookmarks.html rename to tests/modules/programs/firefox/profiles/bookmarks/expected-bookmarks.html diff --git a/tests/modules/programs/firefox/profiles/containers/default.nix b/tests/modules/programs/firefox/profiles/containers/default.nix new file mode 100644 index 000000000..6a0d9e93f --- /dev/null +++ b/tests/modules/programs/firefox/profiles/containers/default.nix @@ -0,0 +1,32 @@ +modulePath: +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = getAttrFromPath modulePath config; + + firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath; + +in { + imports = [ firefoxMockOverlay ]; + + config = mkIf config.test.enableBig (setAttrByPath modulePath { + enable = true; + profiles.containers = { + containers = { + "shopping" = { + icon = "circle"; + color = "yellow"; + }; + }; + }; + } // { + nmt.script = '' + assertFileContent \ + home-files/${cfg.configPath}/containers/containers.json \ + ${./expected-containers.json} + ''; + }); +} diff --git a/tests/modules/programs/firefox/duplicate-container-ids.nix b/tests/modules/programs/firefox/profiles/containers/duplicate-ids.nix similarity index 90% rename from tests/modules/programs/firefox/duplicate-container-ids.nix rename to tests/modules/programs/firefox/profiles/containers/duplicate-ids.nix index 2ad99b4b7..a60522165 100644 --- a/tests/modules/programs/firefox/duplicate-container-ids.nix +++ b/tests/modules/programs/firefox/profiles/containers/duplicate-ids.nix @@ -7,7 +7,7 @@ let cfg = getAttrFromPath modulePath config; - firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath; + firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath; in { imports = [ firefoxMockOverlay ]; diff --git a/tests/modules/programs/firefox/profile-settings-expected-containers.json b/tests/modules/programs/firefox/profiles/containers/expected-containers.json similarity index 66% rename from tests/modules/programs/firefox/profile-settings-expected-containers.json rename to tests/modules/programs/firefox/profiles/containers/expected-containers.json index 8eea55558..d957b0c50 100644 --- a/tests/modules/programs/firefox/profile-settings-expected-containers.json +++ b/tests/modules/programs/firefox/profiles/containers/expected-containers.json @@ -1 +1 @@ -{"identities":[{"color":"yellow","icon":"circle","name":"shopping","public":true,"userContextId":6},{"accessKey":"","color":"","icon":"","name":"userContextIdInternal.thumbnail","public":false,"userContextId":4294967294},{"accessKey":"","color":"","icon":"","name":"userContextIdInternal.webextStorageLocal","public":false,"userContextId":4294967295}],"lastUserContextId":6,"version":4} +{"identities":[{"color":"yellow","icon":"circle","name":"shopping","public":true,"userContextId":0},{"accessKey":"","color":"","icon":"","name":"userContextIdInternal.thumbnail","public":false,"userContextId":4294967294},{"accessKey":"","color":"","icon":"","name":"userContextIdInternal.webextStorageLocal","public":false,"userContextId":4294967295}],"lastUserContextId":0,"version":4} diff --git a/tests/modules/programs/firefox/container-id-out-of-range.nix b/tests/modules/programs/firefox/profiles/containers/id-out-of-range.nix similarity index 86% rename from tests/modules/programs/firefox/container-id-out-of-range.nix rename to tests/modules/programs/firefox/profiles/containers/id-out-of-range.nix index 2ea08e880..f39666723 100644 --- a/tests/modules/programs/firefox/container-id-out-of-range.nix +++ b/tests/modules/programs/firefox/profiles/containers/id-out-of-range.nix @@ -5,7 +5,7 @@ with lib; let - firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath; + firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath; in { imports = [ firefoxMockOverlay ]; diff --git a/tests/modules/programs/firefox/duplicate-profile-ids.nix b/tests/modules/programs/firefox/profiles/duplicate-ids.nix similarity index 87% rename from tests/modules/programs/firefox/duplicate-profile-ids.nix rename to tests/modules/programs/firefox/profiles/duplicate-ids.nix index ad946af10..dc5557b47 100644 --- a/tests/modules/programs/firefox/duplicate-profile-ids.nix +++ b/tests/modules/programs/firefox/profiles/duplicate-ids.nix @@ -7,7 +7,7 @@ let cfg = getAttrFromPath modulePath config; - firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath; + firefoxMockOverlay = import ../setup-firefox-mock-overlay.nix modulePath; in { imports = [ firefoxMockOverlay ]; diff --git a/tests/modules/programs/firefox/profiles/search/default.nix b/tests/modules/programs/firefox/profiles/search/default.nix new file mode 100644 index 000000000..8a4c98e9b --- /dev/null +++ b/tests/modules/programs/firefox/profiles/search/default.nix @@ -0,0 +1,112 @@ +modulePath: +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = getAttrFromPath modulePath config; + + firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath; + +in { + imports = [ firefoxMockOverlay ]; + + config = mkIf config.test.enableBig (setAttrByPath modulePath { + enable = true; + profiles = { + search = { + id = 0; + search = { + force = true; + default = "Google"; + privateDefault = "DuckDuckGo"; + order = [ "Nix Packages" "NixOS Wiki" ]; + engines = { + "Nix Packages" = { + urls = [{ + template = "https://search.nixos.org/packages"; + params = [ + { + name = "type"; + value = "packages"; + } + { + name = "query"; + value = "{searchTerms}"; + } + ]; + }]; + + icon = + "/run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + + definedAliases = [ "@np" ]; + }; + + "NixOS Wiki" = { + urls = [{ + template = + "https://wiki.nixos.org/index.php?search={searchTerms}"; + }]; + iconUpdateURL = "https://wiki.nixos.org/favicon.png"; + updateInterval = 24 * 60 * 60 * 1000; + definedAliases = [ "@nw" ]; + }; + + "Bing".metaData.hidden = true; + "Google".metaData.alias = "@g"; + }; + }; + }; + + searchWithoutDefault = { + id = 1; + search = { + force = true; + order = [ "Google" "Nix Packages" ]; + engines = { + "Nix Packages" = { + urls = [{ + template = "https://search.nixos.org/packages"; + params = [ + { + name = "type"; + value = "packages"; + } + { + name = "query"; + value = "{searchTerms}"; + } + ]; + }]; + + definedAliases = [ "@np" ]; + }; + }; + }; + }; + }; + } // { + nmt.script = '' + function assertFirefoxSearchContent() { + compressedSearch=$(normalizeStorePaths "$1") + + decompressedSearch=$(dirname $compressedSearch)/search.json + ${pkgs.mozlz4a}/bin/mozlz4a -d "$compressedSearch" >(${pkgs.jq}/bin/jq . > "$decompressedSearch") + + assertFileContent \ + $decompressedSearch \ + "$2" + } + + assertFirefoxSearchContent \ + home-files/${cfg.configPath}/search/search.json.mozlz4 \ + ${./expected-search.json} + + assertFirefoxSearchContent \ + home-files/${cfg.configPath}/searchWithoutDefault/search.json.mozlz4 \ + ${./expected-search-without-default.json} + ''; + }); +} diff --git a/tests/modules/programs/firefox/profile-settings-expected-search-without-default.json b/tests/modules/programs/firefox/profiles/search/expected-search-without-default.json similarity index 100% rename from tests/modules/programs/firefox/profile-settings-expected-search-without-default.json rename to tests/modules/programs/firefox/profiles/search/expected-search-without-default.json diff --git a/tests/modules/programs/firefox/profile-settings-expected-search.json b/tests/modules/programs/firefox/profiles/search/expected-search.json similarity index 100% rename from tests/modules/programs/firefox/profile-settings-expected-search.json rename to tests/modules/programs/firefox/profiles/search/expected-search.json diff --git a/tests/modules/programs/firefox/profiles/settings/default.nix b/tests/modules/programs/firefox/profiles/settings/default.nix new file mode 100644 index 000000000..39d329ece --- /dev/null +++ b/tests/modules/programs/firefox/profiles/settings/default.nix @@ -0,0 +1,43 @@ +modulePath: +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = getAttrFromPath modulePath config; + + firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath; + +in { + imports = [ firefoxMockOverlay ]; + + config = mkIf config.test.enableBig (setAttrByPath modulePath { + enable = true; + profiles = { + basic.isDefault = true; + test = { + id = 1; + settings = { + "general.smoothScroll" = false; + "browser.newtabpage.pinned" = [{ + title = "NixOS"; + url = "https://nixos.org"; + }]; + }; + }; + }; + } // { + nmt.script = '' + assertFileRegex \ + home-path/bin/${cfg.wrappedPackageName} \ + MOZ_APP_LAUNCHER + + assertDirectoryExists home-files/${cfg.configPath}/basic + + assertFileContent \ + home-files/${cfg.configPath}/test/user.js \ + ${./expected-user.js} + ''; + }); +} diff --git a/tests/modules/programs/firefox/profile-settings-expected-user.js b/tests/modules/programs/firefox/profiles/settings/expected-user.js similarity index 100% rename from tests/modules/programs/firefox/profile-settings-expected-user.js rename to tests/modules/programs/firefox/profiles/settings/expected-user.js diff --git a/tests/modules/programs/kitty/example-settings-expected.conf b/tests/modules/programs/kitty/example-settings-expected.conf index aca1b0c18..41a9cb772 100644 --- a/tests/modules/programs/kitty/example-settings-expected.conf +++ b/tests/modules/programs/kitty/example-settings-expected.conf @@ -7,6 +7,7 @@ font_size 8 # Shell integration is sourced and configured manually shell_integration no-rc +background_opacity 0.500000 enable_audio_bell no scrollback_lines 10000 update_check_interval 0 diff --git a/tests/modules/programs/kitty/example-settings.nix b/tests/modules/programs/kitty/example-settings.nix index 8d609a5ab..8f2e0b894 100644 --- a/tests/modules/programs/kitty/example-settings.nix +++ b/tests/modules/programs/kitty/example-settings.nix @@ -17,6 +17,7 @@ with lib; scrollback_lines = 10000; enable_audio_bell = false; update_check_interval = 0; + background_opacity = 0.5; }; font.name = "DejaVu Sans"; diff --git a/tests/modules/programs/vifm/default.nix b/tests/modules/programs/vifm/default.nix new file mode 100644 index 000000000..5a75a54aa --- /dev/null +++ b/tests/modules/programs/vifm/default.nix @@ -0,0 +1,4 @@ +{ + vifm-example-settings = ./example-settings.nix; + vifm-empty-settings = ./empty-settings.nix; +} diff --git a/tests/modules/programs/vifm/empty-settings.nix b/tests/modules/programs/vifm/empty-settings.nix new file mode 100644 index 000000000..4e1df9c18 --- /dev/null +++ b/tests/modules/programs/vifm/empty-settings.nix @@ -0,0 +1,11 @@ +{ ... }: + +{ + programs.vifm.enable = true; + + test.stubs.vifm = { }; + + nmt.script = '' + assertPathNotExists home-files/.config/vifm + ''; +} diff --git a/tests/modules/programs/vifm/example-settings.nix b/tests/modules/programs/vifm/example-settings.nix new file mode 100644 index 000000000..8f562aa62 --- /dev/null +++ b/tests/modules/programs/vifm/example-settings.nix @@ -0,0 +1,21 @@ +{ config, ... }: + +{ + programs.vifm = { + enable = true; + package = config.lib.test.mkStubPackage { }; + extraConfig = '' + mark h ~/ + ''; + }; + + nmt.script = '' + assertFileContent \ + home-files/.config/vifm/vifmrc \ + ${ + builtins.toFile "vifm-expected.conf" '' + mark h ~/ + '' + } + ''; +} diff --git a/tests/modules/services/snixembed/basic-configuration.desktop b/tests/modules/services/snixembed/basic-configuration.desktop new file mode 100644 index 000000000..a606d8f2f --- /dev/null +++ b/tests/modules/services/snixembed/basic-configuration.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Exec=@xdg-utils@/bin/xdg-open http://localhost:9494 +Icon=/snixembed/share/snixembed/public/favicon.ico +Name=Snixembed +Terminal=false +Type=Application +Version=1.4 diff --git a/tests/modules/services/snixembed/basic-configuration.nix b/tests/modules/services/snixembed/basic-configuration.nix new file mode 100644 index 000000000..fd8ec4701 --- /dev/null +++ b/tests/modules/services/snixembed/basic-configuration.nix @@ -0,0 +1,16 @@ +{ ... }: + +{ + services.snixembed = { + enable = true; + beforeUnits = [ "safeeyes.service" ]; + }; + + test.stubs = { snixembed = { outPath = "/snixembed"; }; }; + + nmt.script = '' + assertFileContent \ + home-files/.config/systemd/user/snixembed.service \ + ${./basic-configuration.service} + ''; +} diff --git a/tests/modules/services/snixembed/basic-configuration.service b/tests/modules/services/snixembed/basic-configuration.service new file mode 100644 index 000000000..97e87664b --- /dev/null +++ b/tests/modules/services/snixembed/basic-configuration.service @@ -0,0 +1,14 @@ +[Install] +WantedBy=graphical-session.target + +[Service] +ExecStart=/snixembed/bin/dummy +Restart=on-failure +RestartSec=3 + +[Unit] +Before=safeeyes.service +Description=snixembed +PartOf=graphical-session.target +StartLimitBurst=10 +StartLimitIntervalSec=100 diff --git a/tests/modules/services/snixembed/default.nix b/tests/modules/services/snixembed/default.nix new file mode 100644 index 000000000..b49917197 --- /dev/null +++ b/tests/modules/services/snixembed/default.nix @@ -0,0 +1 @@ +{ snixembed-basic-configuration = ./basic-configuration.nix; }