diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-18 17:07:46 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-18 17:07:46 +0200 |
commit | c52c7f314ccadcc2fcd91e28c8fd1b88f6d5ce0c (patch) | |
tree | e8b947710b467b32740598ff574982097836f66c /modules/system/services | |
parent | chore(pkgs/yt): 1.2.1 -> 1.3.0 (diff) | |
download | nixos-config-c52c7f314ccadcc2fcd91e28c8fd1b88f6d5ce0c.tar.gz nixos-config-c52c7f314ccadcc2fcd91e28c8fd1b88f6d5ce0c.zip |
refactor(modules): Move all system modules to `by-name`
From now on all modules should be added to the new `by-name` directory. This should help remove the (superficial and utterly useless) distinction between `home-manager` and `NixOS` modules.
Diffstat (limited to 'modules/system/services')
23 files changed, 0 insertions, 712 deletions
diff --git a/modules/system/services/adb/default.nix b/modules/system/services/adb/default.nix deleted file mode 100644 index ec5d4be6..00000000 --- a/modules/system/services/adb/default.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ - lib, - config, - ... -}: let - cfg = config.soispha.services.adb; -in { - options.soispha.services.adb = { - enable = lib.mkEnableOption "Android adb bridge"; - user = lib.mkOption { - type = lib.types.str; - example = "soispha"; - default = "soispha"; - description = "Username to grant access to adb bridge"; - }; - }; - - config = lib.mkIf cfg.enable { - programs.adb.enable = true; - users.users."${cfg.user}".extraGroups = ["adbusers"]; - }; -} diff --git a/modules/system/services/backup/default.nix b/modules/system/services/backup/default.nix deleted file mode 100644 index 92700bf2..00000000 --- a/modules/system/services/backup/default.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ - lib, - pkgs, - config, - ... -}: let - backup-script = pkgs.writeShellScriptBin "backsnap" '' - set -xeu; - - ${pkgs.util-linux}/bin/mount --mkdir "/dev/disk/by-uuid/${cfg.backupDiskUuid}" "/run/media/${cfg.backupDiskUuid}"; - ${pkgs.snap-sync-forked}/bin/snap-sync-forked --UUID "${cfg.backupDiskUuid}" --noconfirm; - ${pkgs.util-linux}/bin/umount "/run/media/${cfg.backupDiskUuid}"; - ''; - - cfg = config.soispha.services.backup; -in { - options.soispha.services.backup = { - enable = lib.mkEnableOption "backups with my forked snap-sync"; - backupDiskUuid = lib.mkOption { - type = lib.types.str; - example = lib.literalExpression "d1d20ae7-3d8a-44da-86da-677dbbb10c89"; - description = "The UUID of the backup disk"; - }; - }; - - config = lib.mkIf cfg.enable { - systemd = { - services.backup = { - wantedBy = lib.mkForce []; - unitConfig = { - Description = "Backup the last snapshots of the persitent-storage subvolume."; - }; - serviceConfig = { - Type = "oneshot"; - ExecStart = "${backup-script}/bin/backsnap"; - }; - }; - - timers.backup = { - wantedBy = ["timers.target"]; - unitConfig = { - Description = "Backup 15min after boot and every 8 hours"; - }; - timerConfig = { - OnBootSec = "15min"; - OnUnitActiveSec = "8h"; - }; - }; - }; - }; -} diff --git a/modules/system/services/dconf/default.nix b/modules/system/services/dconf/default.nix deleted file mode 100644 index e4a1c7a9..00000000 --- a/modules/system/services/dconf/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{...}: { - # needed to make home-manager play nice with some apps. See: - # https://nix-community.github.io/home-manager/index.xhtml#_why_do_i_get_an_error_message_about_literal_ca_desrt_dconf_literal_or_literal_dconf_service_literal - programs.dconf.enable = true; - # FIXME: This should also be parameterized. <2024-05-16> -} -# vim: nolinebreak nowrap textwidth=0 - diff --git a/modules/system/services/default.nix b/modules/system/services/default.nix deleted file mode 100644 index b5d500bd..00000000 --- a/modules/system/services/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -{...}: { - imports = [ - #./serverphone - ./adb - ./backup - ./dconf - ./fwupd - ./issue_file - ./nix - ./openssh - ./postgresql - ./printing - ./scanning - ./snapper - ./steam - ./swaylock - ./system_diff - ./xdg - ]; -} diff --git a/modules/system/services/fwupd/default.nix b/modules/system/services/fwupd/default.nix deleted file mode 100644 index 5ad4f467..00000000 --- a/modules/system/services/fwupd/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - config, - lib, - ... -}: let - cfg = config.soispha.services.fwupd; -in { - options.soispha.services.fwupd = { - enable = lib.mkEnableOption "fwupd"; - }; - config = lib.mkIf cfg.enable { - services.fwupd.enable = true; - }; -} diff --git a/modules/system/services/issue_file/default.nix b/modules/system/services/issue_file/default.nix deleted file mode 100644 index d8b6faa8..00000000 --- a/modules/system/services/issue_file/default.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ - config, - self, - pkgs, - lib, - ... -}: let - lastModifiedFile = pkgs.runCommandLocal "formatDate" {} '' - date --date='@${builtins.toString self.sourceInfo.lastModified}' +'%F %T' > $out - ''; - lastModified = lib.strings.replaceStrings ["\n"] [""] ( - builtins.readFile lastModifiedFile - ); -in { - environment.etc.issue = { - # Friendly greeting on the virtual consoles. - text = '' - [?25l[?7l[38;2;255;77;77m [39m[49m - [38;2;255;77;77m ▗▄▄▄ ▗▄▄▄▄ ▄▄▄▖ [39m[49m - [38;2;255;77;77m ▜███▙ ▜███▙ ▟███▛ [39m[49m - [38;2;255;77;77m ▜███▙ ▜███▙▟███▛ [39m[49m - [38;2;255;175;77m ▜███▙ ▜██████▛ [39m[49m - [38;2;255;175;77m ▟█████████████████▙ ▜████▛ ▟▙ [39m[49m - [38;2;255;175;77m ▟███████████████████▙ ▜███▙ ▟██▙ [39m[49m - [38;2;255;175;77m ▄▄▄▄▖ ▜███▙ ▟███▛ [39m[49m - [38;2;255;243;77m ▟███▛ ▜██▛ ▟███▛ [39m[49m - [38;2;255;243;77m ▟███▛ ▜▛ ▟███▛ [39m[49m - [38;2;255;243;77m▟███████████▛ ▟██████████▙[39m[49m - [38;2;79;252;121m▜██████████▛ ▟███████████▛[39m[49m - [38;2;79;252;121m ▟███▛ ▟▙ ▟███▛ [39m[49m - [38;2;79;252;121m ▟███▛ ▟██▙ ▟███▛ [39m[49m - [38;2;77;130;255m ▟███▛ ▜███▙ ▝▀▀▀▀ [39m[49m - [38;2;77;130;255m ▜██▛ ▜███▙ ▜██████████████████▛ [39m[49m - [38;2;77;130;255m ▜▛ ▟████▙ ▜████████████████▛ [39m[49m - [38;2;77;130;255m ▟██████▙ ▜███▙ [39m[49m - [38;2;233;77;255m ▟███▛▜███▙ ▜███▙ [39m[49m - [38;2;233;77;255m ▟███▛ ▜███▙ ▜███▙ [39m[49m - [38;2;233;77;255m ▝▀▀▀ ▀▀▀▀▘ ▀▀▀▘ [39m[49m - [38;2;233;77;255m [39m[49m[0m - [17A[9999999D[46C[34m[1m NixOS ${config.system.nixos.label} [0m - [46C[0m --------------[0m - [46C - [46C [34m[1m last update: [0m${lastModified} - [46C [34m[1m date: [0m\d - [46C [34m[1m time: [0m\t - [46C [34m[1m ipv4: [0m\4 - [46C [34m[1m ipv6: [0m\6 - [46C [34m[1m tty: [0m\l - [22B - ''; - }; -} diff --git a/modules/system/services/nix/default.nix b/modules/system/services/nix/default.nix deleted file mode 100644 index 980bbd39..00000000 --- a/modules/system/services/nix/default.nix +++ /dev/null @@ -1,61 +0,0 @@ -{ - pkgs, - # flakes - nixpkgs_as_input, - templates, - self, - system, - ... -}: { - nix = { - package = pkgs.nixVersions.latest; - - # Disable nix channels (this is a remnant of old days) - channel.enable = false; - - registry = { - nixpkgs.flake = nixpkgs_as_input; - n.flake = - nixpkgs_as_input - // { - # Otherwise nixpkgs's config and overlays are not available: - - # Both attrs exists, so we just override both and hope - outputs.legacyPackages."${system}" = pkgs; - legacyPackages."${system}" = pkgs; - }; - - t.flake = templates; - - my_flake.flake = self; - m.flake = self; - }; - - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 7d"; - }; - - settings = { - auto-optimise-store = true; - experimental-features = [ - "nix-command" - "flakes" - #"ca-derivations" - ]; - - use-xdg-base-directories = true; - - #substituters = ["https://cache.ngi0.nixos.org/"]; - #trusted-public-keys = ["cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA="]; - - fallback = true; # Build from source, if binary can't be substituted - - keep-failed = true; # keep failed tmp build dirs - pure-eval = true; # restrict file system and network access to hash - - sandbox-fallback = false; # Don't disable the sandbox, if the kernel doesn't support it - }; - }; -} diff --git a/modules/system/services/openssh/default.nix b/modules/system/services/openssh/default.nix deleted file mode 100644 index b733dbe7..00000000 --- a/modules/system/services/openssh/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -{...}: { - services.openssh = { - enable = true; - hostKeys = [ - { - path = "/srv/sshd/ssh_host_ed25519_key"; - rounds = 1000; - type = "ed25519"; - } - ]; - settings = { - PasswordAuthentication = false; - }; - }; -} diff --git a/modules/system/services/postgresql/default.nix b/modules/system/services/postgresql/default.nix deleted file mode 100644 index c47a235c..00000000 --- a/modules/system/services/postgresql/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - config, - lib, - ... -}: let - cfg = config.soispha.services.postgresql; -in { - options.soispha.services.postgresql = { - enable = lib.mkEnableOption "postgresql"; - }; - - config = lib.mkIf cfg.enable { - services.postgresql = { - enable = true; - }; - }; -} diff --git a/modules/system/services/printing/default.nix b/modules/system/services/printing/default.nix deleted file mode 100644 index 85d15b16..00000000 --- a/modules/system/services/printing/default.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ - config, - lib, - ... -}: let - cfg = config.soispha.services.printing; -in { - options.soispha.services.printing = { - enable = lib.mkEnableOption "default printing configuration"; - }; - - config = lib.mkIf cfg.enable { - services.avahi = { - enable = true; - nssmdns4 = true; - nssmdns6 = true; - openFirewall = true; - }; - - services.printing = { - enable = true; - startWhenNeeded = true; - webInterface = true; - - # deletes `/var/cache/cups`, `/var/lib/cups` and `/var/spool/cups` on cups startup - stateless = true; - - drivers = []; - }; - - hardware = { - printers = { - ensurePrinters = [ - { - name = "Brother"; - description = "Brother DCP-9022CDW"; - model = "everywhere"; - deviceUri = "dnssd://Brother%20DCP-9022CDW._ipp._tcp.local/?uuid=e3248000-80ce-11db-8000-30055c773bcf"; - } - ]; - ensureDefaultPrinter = "Brother"; - }; - }; - }; -} diff --git a/modules/system/services/scanning/default.nix b/modules/system/services/scanning/default.nix deleted file mode 100644 index dda507fa..00000000 --- a/modules/system/services/scanning/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - cfg = config.soispha.services.scanning; -in { - options.soispha.services.scanning = { - enable = lib.mkEnableOption "default scanning configuration"; - }; - - config = lib.mkIf cfg.enable { - hardware = { - sane = { - enable = true; - extraBackends = [pkgs.sane-airscan]; - }; - }; - - users.users.soispha.extraGroups = [ - "scanner" # for permission to access the scanner. - ]; - }; -} diff --git a/modules/system/services/serverphone/certificates/ca.crt b/modules/system/services/serverphone/certificates/ca.crt deleted file mode 100644 index 7a4ae6f9..00000000 --- a/modules/system/services/serverphone/certificates/ca.crt +++ /dev/null @@ -1,10 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIBXDCCAQOgAwIBAgIIRQ2wXiaD5pMwCgYIKoZIzj0EAwIwGTEXMBUGA1UEAwwO -U2VydmVycGhvbmUgQ0EwHhcNMjMwNjA2MTIzNzM3WhcNMzMwNjAzMTIzNzM3WjAZ -MRcwFQYDVQQDDA5TZXJ2ZXJwaG9uZSBDQTBZMBMGByqGSM49AgEGCCqGSM49AwEH -A0IABDZMtz3liWniBedisStXDO2sxFCKBH239ezH7uADu8g5peGssmNu1rXEDrg1 -sFwVUjQeJAocYYNoUeHiVpODf1ejNTAzMB0GA1UdDgQWBBST5oMmXrANRbCLIQpN -W7e5uSCL3DASBgNVHRMBAf8ECDAGAQH/AgEBMAoGCCqGSM49BAMCA0cAMEQCIFig -xA3MvRNP4uXaUEWwdP1pYL/R8N46G4NZrPEfiNV4AiA+NJSTFRCOUqEsvSb7PTFx -YuMuJF4XxWnmStz3ym7xXA== ------END CERTIFICATE----- diff --git a/modules/system/services/serverphone/certificates/server.crt b/modules/system/services/serverphone/certificates/server.crt deleted file mode 100644 index f994cdc8..00000000 --- a/modules/system/services/serverphone/certificates/server.crt +++ /dev/null @@ -1,10 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIBTjCB9KADAgECAgkAhKrdjsoiOrkwCgYIKoZIzj0EAwIwGTEXMBUGA1UEAwwO -U2VydmVycGhvbmUgQ0EwHhcNMjMwNjA2MTIzOTIwWhcNMjQwNjA1MTIzOTIwWjAm -MSQwIgYDVQQDDBtDbGllbnQgcnVubmluZyBvbiBsb2NhbGhvc3QwWTATBgcqhkjO -PQIBBggqhkjOPQMBBwNCAAS1ILQo8ae8ydqFlt5RncUT7joQiozk6Omunb0vxVz5 -toJRDmVqc1s6KhpCTipUV5coTcaK1TBz0+fft+9VH7cwoxgwFjAUBgNVHREEDTAL -gglsb2NhbGhvc3QwCgYIKoZIzj0EAwIDSQAwRgIhAN7ohtsBLrjlgmSe9ngovxZM -z61n0+/7w2mtX/OrLMWIAiEAu+D2S2o0s7E9pp2Rkug8cT5T4GCWgFgEHk5x2L/E -RVI= ------END CERTIFICATE----- diff --git a/modules/system/services/serverphone/default.nix b/modules/system/services/serverphone/default.nix deleted file mode 100644 index 20125a75..00000000 --- a/modules/system/services/serverphone/default.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - config, - serverphone, - system, - lib, - ... -}: { - config = lib.mkIf config.soispha.secrets.enable { - services.serverphone = { - package = "${serverphone.packages.${system}.default}"; - enable = true; - domain = "localhost"; - configureDoas = true; - acceptedSshKeys = [ - "AAAAC3NzaC1lZDI1NTE5AAAAIGBFuTNNn71Rhfnop2cdz3r/RhWWlCePnSBOhTBbu2ME" - ]; - authorized = { - acceptedGpgKeys = [ - { - source = ./keys/key_1; - trust = "ultimate"; - } - { - source = ./keys/key_2; - trust = "ultimate"; - } - ]; - }; - caCertificate = "${./certificates/ca.crt}"; - certificate = "${./certificates/server.crt}"; - privateKey = config.age.secrets.serverphoneServer.path; - certificateRequest = { - acceptedUsers = [ - "soispha $argon2id$v=19$m=19456,t=2,p=1$EvhPENIBqL5b1RO5waNMWA$pJ8vDrCNJKDlqwB5bVDLjHVPEXm9McQhtt9OXSD8Zkc" - ]; - caPrivateKey = config.age.secrets.serverphoneCa.path; - }; - }; - - users.users.serverphone = { - group = "serverphone"; - isSystemUser = true; - home = "/run/serverphone"; - }; - users.groups.serverphone = { - members = ["serverphone"]; - }; - }; -} diff --git a/modules/system/services/serverphone/keys/key_1 b/modules/system/services/serverphone/keys/key_1 deleted file mode 120000 index 67720882..00000000 --- a/modules/system/services/serverphone/keys/key_1 +++ /dev/null @@ -1 +0,0 @@ -../../../../home-manager/soispha/config/gpg/keys/key_1 \ No newline at end of file diff --git a/modules/system/services/serverphone/keys/key_2 b/modules/system/services/serverphone/keys/key_2 deleted file mode 120000 index 24df7207..00000000 --- a/modules/system/services/serverphone/keys/key_2 +++ /dev/null @@ -1 +0,0 @@ -../../../../home-manager/soispha/config/gpg/keys/key_2 \ No newline at end of file diff --git a/modules/system/services/snapper/default.nix b/modules/system/services/snapper/default.nix deleted file mode 100644 index bf8201a4..00000000 --- a/modules/system/services/snapper/default.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ - config, - lib, - ... -}: let - cfg = config.soispha.services.snapper; -in { - options.soispha.services.snapper = { - enable = lib.mkEnableOption "snapper config"; - }; - - config = lib.mkIf cfg.enable { - services.snapper = { - configs = { - srv = { - SUBVOLUME = "/srv"; - FSTYPE = "btrfs"; - # users and groups allowed to work with config - ALLOW_GROUPS = ["wheel"]; - - # sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots - # directory - SYNC_ACL = true; - - # run daily number cleanup - NUMBER_CLEANUP = false; - - # limit for number cleanup - NUMBER_MIN_AGE = 1800; - NUMBER_LIMIT = 50; - NUMBER_LIMIT_IMPORTANT = 10; - - # create hourly snapshots - TIMELINE_CREATE = true; - - # cleanup hourly snapshots after some time - TIMELINE_CLEANUP = true; - - # limits for timeline cleanup - TIMELINE_MIN_AGE = 1800; - TIMELINE_LIMIT_HOURLY = 7; - TIMELINE_LIMIT_DAILY = 3; - TIMELINE_LIMIT_WEEKLY = 2; - TIMELINE_LIMIT_MONTHLY = 0; - TIMELINE_LIMIT_YEARLY = 2; - - # cleanup empty pre-post-pairs - EMPTY_PRE_POST_CLEANUP = true; - }; - }; - }; - }; -} diff --git a/modules/system/services/steam/default.nix b/modules/system/services/steam/default.nix deleted file mode 100644 index 49149cd7..00000000 --- a/modules/system/services/steam/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - lib, - config, - pkgs, - ... -}: let - cfg = config.soispha.services.steam; -in { - options.soispha.services.steam = { - enable = lib.mkEnableOption "Steam"; - }; - - config = lib.mkIf cfg.enable { - programs.steam = { - enable = true; - }; - - environment.systemPackages = [ - # TODO: Why is this package needed? <2024-05-16> - pkgs.wineWowPackages.waylandFull - ]; - }; -} diff --git a/modules/system/services/swaylock/default.nix b/modules/system/services/swaylock/default.nix deleted file mode 100644 index 6cbcef28..00000000 --- a/modules/system/services/swaylock/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{...}: { - # otherwise swaylock can't access the user password. - security.pam.services.swaylock = {}; -} diff --git a/modules/system/services/system_diff/default.nix b/modules/system/services/system_diff/default.nix deleted file mode 100644 index 052ffae2..00000000 --- a/modules/system/services/system_diff/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - cfg = config.soispha.services.systemDiff; -in { - options.soispha.services.systemDiff = { - enable = lib.mkEnableOption "nvd run at system activation"; - }; - - config = lib.mkIf cfg.enable { - system.activationScripts.diff = { - supportsDryActivation = true; - text = '' - PATH="${lib.makeBinPath [pkgs.nvd config.nix.package]}:$PATH" - - if [ -e /run/current-system ]; then - # ${lib.getExe config.nix.package} --extra-experimental-features nix-command store diff-closures /run/current-system "$systemConfig" - nvd diff $(ls -dv /nix/var/nix/profiles/system-*-link | tail -2) - fi - ''; - }; - }; -} diff --git a/modules/system/services/xdg/default.nix b/modules/system/services/xdg/default.nix deleted file mode 100644 index 5140a832..00000000 --- a/modules/system/services/xdg/default.nix +++ /dev/null @@ -1,58 +0,0 @@ -{ - pkgs, - nixpkgs_open_prs, - sysLib, - system, - ... -}: let - pkgs_tfc = nixpkgs_open_prs.nixpkgs-tfc.legacyPackages."${system}"; -in { - services.dbus.enable = true; - xdg = { - portal = { - enable = true; - termfilechooser = { - enable = true; - logLevel = "TRACE"; - package = pkgs_tfc.xdg-desktop-portal-termfilechooser; - settings = { - filechooser = { - default_dir = "/tmp"; - cmd = "${sysLib.writeShellScript { - src = ./scripts/lf_wrapper.sh; - name = "lf_wrapper"; - keepPath = true; - dependencies = with pkgs; [ - lf - alacritty - bash - ]; - }}/bin/lf_wrapper"; - }; - }; - }; - wlr = { - enable = true; - }; - config = { - common = { - # NOTE: The next entry is supposedly needed for gtk based apps <2023-08-31> - default = ["wlr" "gtk"]; - "org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"]; - }; - - # TODO: Also activate, when on another wlr-based compositor <2023-11-25> - river = { - default = ["wlr" "gtk"]; - "org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"]; - }; - }; - extraPortals = [ - pkgs.xdg-desktop-portal-gtk - pkgs.xdg-desktop-portal-wlr - pkgs_tfc.xdg-desktop-portal-termfilechooser - ]; - }; - }; - # TODO: mime = {}; -} diff --git a/modules/system/services/xdg/scripts/lf_wrapper.sh b/modules/system/services/xdg/scripts/lf_wrapper.sh deleted file mode 100755 index 16603fe4..00000000 --- a/modules/system/services/xdg/scripts/lf_wrapper.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# This wrapper script is invoked by xdg-desktop-portal-termfilechooser. -# -# Inputs: -# 1. "1" if multiple files can be chosen, "0" otherwise. -# 2. "1" if a directory should be chosen, "0" otherwise. -# 3. "0" if opening files was requested, "1" if writing to a file was -# requested. For example, when uploading files in Firefox, this will be "0". -# When saving a web page in Firefox, this will be "1". -# 4. If writing to a file, this is recommended path provided by the caller. For -# example, when saving a web page in Firefox, this will be the recommended -# path Firefox provided, such as "~/Downloads/webpage_title.html". -# Note that if the path already exists, we keep appending "_" to it until we -# get a path that does not exist. -# 5. The output path, to which results should be written. -# -# Output: -# The script should print the selected paths to the output path (argument #5), -# one path per line. -# If nothing is printed, then the operation is assumed to have been canceled. - -multiple="$1" -directory="$2" -save="$3" -recommended_path="$4" -out="$5" - -# echo > /tmp/stdout -# echo > /tmp/stderr -# -# exec 1>> /tmp/stdout -# exec 2>> /tmp/stderr - -cmd="$(command -v lf)" -termcmd="${TERMINAL:-$(command -v alacritty)}" - -if [ "$save" = "1" ]; then - set -- -selection-path="$out" -command='set promptfmt "Select the file to write to %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' "$recommended_path" - cat <<EOF >"$recommended_path" -xdg-desktop-portal-termfilechooser saving files tutorial - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!!! === WARNING! === !!! -!!! The contents of *whatever* file you open last in !!! -!!! lf will be *overwritten*! !!! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -Instructions: -1) Move this file wherever you want. -2) Rename the file if needed. -3) Confirm your selection by opening the file, for - example by pressing <Enter>. - -Notes: -1) This file is provided for your convenience. You - could delete it and choose another file to overwrite - that, for example. -2) If you quit lf without opening a file, this file - will be removed and the save operation aborted. -EOF - -elif [ "$directory" = "1" ]; then - set -- -selection-path="$out" -command='set dironly' -command='set promptfmt "Select directory (quit in dir to select it) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' -elif [ "$multiple" = "1" ]; then - set -- -selection-path="$out" -command='set promptfmt "Select file(s) (open file to select it; <Space> to select multiple) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' -else - set -- -selection-path="$out" -command='set promptfmt "Select file (open file to select it) %S \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"' -fi - -"$termcmd" --title 'floating please' -e "$cmd" "$@" - -if [ "$save" = "1" ] && [ ! -s "$out" ]; then - rm "$recommended_path" -fi -# vim: ft=sh diff --git a/modules/system/services/xdg/scripts/ranger_wrapper.sh b/modules/system/services/xdg/scripts/ranger_wrapper.sh deleted file mode 100755 index e148bf19..00000000 --- a/modules/system/services/xdg/scripts/ranger_wrapper.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH -# This wrapper script is invoked by xdg-desktop-portal-termfilechooser. -# -# Inputs: -# 1. "1" if multiple files can be chosen, "0" otherwise. -# 2. "1" if a directory should be chosen, "0" otherwise. -# 3. "0" if opening files was requested, "1" if writing to a file was -# requested. For example, when uploading files in Firefox, this will be "0". -# When saving a web page in Firefox, this will be "1". -# 4. If writing to a file, this is recommended path provided by the caller. For -# example, when saving a web page in Firefox, this will be the recommended -# path Firefox provided, such as "~/Downloads/webpage_title.html". -# Note that if the path already exists, we keep appending "_" to it until we -# get a path that does not exist. -# 5. The output path, to which results should be written. -# -# Output: -# The script should print the selected paths to the output path (argument #5), -# one path per line. -# If nothing is printed, then the operation is assumed to have been canceled. - -multiple="$1" -directory="$2" -save="$3" -path="$4" -out="$5" - -cmd="$(command -v ranger)" -termcmd="${TERMCMD:-$(command -v kitty)}" - -if [ "$save" = "1" ]; then - set -- --choosefile="$out" --cmd='echo Select save path (see tutorial in preview pane; try pressing zv or zp if no preview)' "$path" - printf '%s' 'xdg-desktop-portal-termfilechooser saving files tutorial - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!!! === WARNING! === !!! -!!! The contents of *whatever* file you open last in !!! -!!! ranger will be *overwritten*! !!! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -Instructions: -1) Move this file wherever you want. -2) Rename the file if needed. -3) Confirm your selection by opening the file, for - example by pressing <Enter>. - -Notes: -1) This file is provided for your convenience. You - could delete it and choose another file to overwrite - that, for example. -2) If you quit ranger without opening a file, this file - will be removed and the save operation aborted. -' >"$path" -elif [ "$directory" = "1" ]; then - set -- --choosedir="$out" --show-only-dirs --cmd="echo Select directory (quit in dir to select it)" -elif [ "$multiple" = "1" ]; then - set -- --choosefiles="$out" --cmd="echo Select file(s) (open file to select it; <Space> to select multiple)" -else - set -- --choosefile="$out" --cmd="echo Select file (open file to select it)" -fi - -"$termcmd" -- "$cmd" "$@" -if [ "$save" = "1" ] && [ ! -s "$out" ]; then - rm "$path" -fi |