diff --git a/modules/applications.nix b/modules/applications.nix index 98002d8..0296204 100755 --- a/modules/applications.nix +++ b/modules/applications.nix @@ -1,5 +1,4 @@ -{ pkgs, config, lib, ... }: -{ +{ pkgs, config, lib, ... }: { options.defaultApplications = lib.mkOption { type = lib.types.attrs; description = "Preferred applications"; @@ -11,7 +10,8 @@ desktop = "alacritty"; }; editor = { - cmd = "${config.home-manager.users.balsoft.programs.emacs.finalPackage}/bin/emacsclient -c $@"; + cmd = + "${config.home-manager.users.balsoft.programs.emacs.finalPackage}/bin/emacsclient -c $@"; desktop = "emacsclient"; }; browser = { @@ -53,33 +53,40 @@ VISUAL = config.defaultApplications.editor.cmd; }; - home-manager.users.balsoft.xdg.mimeApps = { - enable = true; - defaultApplications = - with config.defaultApplications; - builtins.mapAttrs (name: value: - if value ? desktop then [ "${value.desktop}.desktop" ] else value) { - "text/html" = browser; - "image/*" = { desktop = "org.gnome.eog"; }; - "application/zip" = archive; - "application/rar" = archive; - "application/7z" = archive; - "application/*tar" = archive; - "x-scheme-handler/http" = browser; - "x-scheme-handler/https" = browser; - "x-scheme-handler/about" = browser; - "x-scheme-handler/mailto" = mail; - "x-scheme-handler/matrix" = matrix; - "application/pdf" = { desktop = "org.kde.okular"; }; - "application/vnd.openxmlformats-officedocument.wordprocessingml.document" = - text_processor; - "application/msword" = text_processor; - "application/vnd.oasis.opendocument.text" = text_processor; - "text/csv" = spreadsheet; - "application/vnd.oasis.opendocument.spreadsheet" = spreadsheet; - "text/plain" = - editor; # This actually makes Emacs an editor for everything... XDG is wierd - }; + home-manager.users.balsoft = { + home.activation."mimeapps-remove" = { + before = [ "checkLinkTargets" ]; + after = [ ]; + data = "rm -f /home/balsoft/.config/mimeapps.list"; + }; + + xdg.mimeApps = { + enable = true; + defaultApplications = with config.defaultApplications; + builtins.mapAttrs (name: value: + if value ? desktop then [ "${value.desktop}.desktop" ] else value) { + "text/html" = browser; + "image/*" = { desktop = "org.gnome.eog"; }; + "application/zip" = archive; + "application/rar" = archive; + "application/7z" = archive; + "application/*tar" = archive; + "x-scheme-handler/http" = browser; + "x-scheme-handler/https" = browser; + "x-scheme-handler/about" = browser; + "x-scheme-handler/mailto" = mail; + "x-scheme-handler/matrix" = matrix; + "application/pdf" = { desktop = "org.kde.okular"; }; + "application/vnd.openxmlformats-officedocument.wordprocessingml.document" = + text_processor; + "application/msword" = text_processor; + "application/vnd.oasis.opendocument.text" = text_processor; + "text/csv" = spreadsheet; + "application/vnd.oasis.opendocument.spreadsheet" = spreadsheet; + "text/plain" = + editor; # This actually makes Emacs an editor for everything... XDG is wierd + }; + }; }; }; } diff --git a/modules/persist.nix b/modules/persist.nix index d813010..5271d39 100644 --- a/modules/persist.nix +++ b/modules/persist.nix @@ -2,7 +2,7 @@ let cfg = config.persist; - takeAll = what: builtins.concatMap (x: x.${what}); + takeAll = what: concatMap (x: x.${what}); persists = with cfg; [ state derivative cache ]; @@ -15,64 +15,68 @@ let allEtcFiles = absoluteEtcFiles (takeAll "etcFiles" persists); allDirectories = takeAll "directories" persists; + + inherit (builtins) concatMap; + inherit (lib) mkIf; + in { - options = with lib; - with types; - let - common = { - directories = mkOption { - type = listOf path; - default = [ ]; - }; - etcFiles = mkOption { - type = listOf str; - default = [ ]; - }; - homeFiles = mkOption { - type = listOf str; - default = [ ]; - }; + options = let + inherit (lib) mkOption mkEnableOption; + inherit (lib.types) listOf path str; + common = { + directories = mkOption { + type = listOf path; + default = [ ]; }; - in { - persist = { - - enable = mkEnableOption "a tmpfs root with explicit opt-in state"; - - persistRoot = mkOption { - type = path; - default = "/persist"; - }; - - homeDir = mkOption { - type = path; - default = "/home/balsoft"; - }; - - # Stuff that matters - # TODO backups of this stuff - state = { - # backup = {...}; - } // common; - - # Stuff that can be computed from declarative+state, but is never invalidated (so shouldn't be cleaned up) - derivative = common; - - # Stuff that's just there to speed up the system - # It's cleaned up regularly, to solve the cache invalidation problem once and for all - cache = { - clean = { - enable = mkEnableOption "cleaning the cache files and directories"; - dates = mkOption { - type = str; - default = "weekly"; - description = - "A systemd.time calendar description of when to clean the cache files"; - }; - }; - } // common; - + etcFiles = mkOption { + type = listOf str; + default = [ ]; + }; + homeFiles = mkOption { + type = listOf str; + default = [ ]; }; }; + in { + persist = { + + enable = mkEnableOption "a tmpfs root with explicit opt-in state"; + + persistRoot = mkOption { + type = path; + default = "/persist"; + }; + + homeDir = mkOption { + type = path; + default = "/home/balsoft"; + }; + + # Stuff that matters + # TODO backups of this stuff + state = { + # backup = {...}; + } // common; + + # Stuff that can be computed from declarative+state, but is never invalidated (so shouldn't be cleaned up) + derivative = common; + + # Stuff that's just there to speed up the system + # It's cleaned up regularly, to solve the cache invalidation problem once and for all + cache = { + clean = { + enable = mkEnableOption "cleaning the cache files and directories"; + dates = mkOption { + type = str; + default = "weekly"; + description = + "A systemd.time calendar description of when to clean the cache files"; + }; + }; + } // common; + + }; + }; imports = [ inputs.impermanence.nixosModules.impermanence @@ -94,7 +98,7 @@ in { }) ]; - config = lib.mkIf cfg.enable { + config = mkIf cfg.enable { environment.persistence.${cfg.persistRoot} = { directories = allDirectories; files = allEtcFiles; @@ -106,10 +110,9 @@ in { fsType = "tmpfs"; }; - boot.initrd.postMountCommands = assert - config.fileSystems ? ${cfg.persistRoot} - && config.fileSystems.${cfg.persistRoot}.neededForBoot; - '' + boot.initrd.postMountCommands = assert config.fileSystems + ? ${cfg.persistRoot} + && config.fileSystems.${cfg.persistRoot}.neededForBoot; '' mkdir -p /mnt-root/nix mount --bind /mnt-root${cfg.persistRoot}/nix /mnt-root/nix chmod 755 /mnt-root diff --git a/modules/workspace/autoRun.nix b/modules/workspace/autoRun.nix new file mode 100644 index 0000000..e17caf8 --- /dev/null +++ b/modules/workspace/autoRun.nix @@ -0,0 +1,14 @@ +{ config, pkgs, lib, ... }: { + home-manager.users.balsoft = { + + programs.command-not-found = { + enable = true; + dbPath = ../../misc/programs.sqlite; + }; + + }; + + environment.sessionVariables = { + NIX_AUTO_RUN = "1"; + }; +} diff --git a/modules/workspace/direnv.nix b/modules/workspace/direnv.nix new file mode 100644 index 0000000..912c6b3 --- /dev/null +++ b/modules/workspace/direnv.nix @@ -0,0 +1,8 @@ +{ config, pkgs, lib, ... }: { + home-manager.users.balsoft = { + programs.direnv.enable = true; + programs.direnv.enableNixDirenvIntegration = true; + }; + persist.state.directories = + [ "/home/balsoft/.local/share/direnv" ]; +} diff --git a/modules/workspace/gnome3/default.nix b/modules/workspace/gnome3/default.nix index 4a88499..b97b62b 100644 --- a/modules/workspace/gnome3/default.nix +++ b/modules/workspace/gnome3/default.nix @@ -13,31 +13,28 @@ gnome-online-miners.enable = true; }; - environment.sessionVariables.XDG_CURRENT_DESKTOP = "X-Generic"; - - persist.state.directories = map (x: "/home/balsoft/${x}") [ - "Pictures" - "Documents" - "Downloads" - "Music" - "projects" - "Videos" - ]; - services.gvfs.enable = true; services.geoclue2.enable = true; + + fileSystems = with config.persist; + lib.mkIf enable (builtins.listToAttrs (map (name: { + inherit name; + value.options = [ "x-gvfs-hide" ]; + }) (state.directories ++ cache.directories ++ derivative.directories))); + home-manager.users.balsoft = { - xdg.userDirs.enable = true; - - home.activation.gnome = '' $DRY_RUN_CMD mkdir -p "$XDG_DATA_HOME/keyrings" $DRY_RUN_CMD ln -sf ${config.secrets-envsubst.gnome-keyring} "$XDG_DATA_HOME/keyrings/Default_keyring.keyring" echo "Default_keyring" > "$XDG_DATA_HOME/keyrings/default" $DRY_RUN_CMD mkdir -p "$XDG_CONFIG_HOME/goa-1.0" - $DRY_RUN_CMD ln -sf ${./accounts.conf} "$XDG_CONFIG_HOME/goa-1.0/accounts.conf" + $DRY_RUN_CMD ln -sf ${ + ./accounts.conf + } "$XDG_CONFIG_HOME/goa-1.0/accounts.conf" $DRY_RUN_CMD mkdir -p "$XDG_CONFIG_HOME/evolution/sources" - $DRY_RUN_CMD ln -sf ${./nextcloud.source} "$XDG_CONFIG_HOME/evolution/sources/nextcloud.source" + $DRY_RUN_CMD ln -sf ${ + ./nextcloud.source + } "$XDG_CONFIG_HOME/evolution/sources/nextcloud.source" ''; dconf.settings = { @@ -71,13 +68,9 @@ thumbnail-limit = 10; }; - "org/gnome/desktop/interface" = { - cursor-theme = "default"; - }; + "org/gnome/desktop/interface" = { cursor-theme = "default"; }; - "org/gnome/evince/default" = { - inverted-colors = true; - }; + "org/gnome/evince/default" = { inverted-colors = true; }; "org/gnome/maps" = { night-mode = true; diff --git a/modules/workspace/kde/default.nix b/modules/workspace/kde/default.nix index 5d00b6f..da20d8d 100644 --- a/modules/workspace/kde/default.nix +++ b/modules/workspace/kde/default.nix @@ -6,7 +6,6 @@ with pkgs.my-lib; { services.udev.packages = [ pkgs.libmtp pkgs.media-player-info ]; environment.sessionVariables = { - DESKTOP_SESSION = "kde"; QT_XFT = "true"; QT_SELECT = "5"; KDE_SESSION_VERSION = "5"; diff --git a/modules/workspace/misc.nix b/modules/workspace/misc.nix index b11d0d6..39c62ec 100644 --- a/modules/workspace/misc.nix +++ b/modules/workspace/misc.nix @@ -1,49 +1,28 @@ { pkgs, lib, config, inputs, ... }: { - systemd.coredump.enable = true; - - systemd.services.systemd-timesyncd.wantedBy = [ "multi-user.target" ]; - - systemd.timers.systemd-timesyncd = { - timerConfig.OnCalendar = "hourly"; - }; environment.sessionVariables = config.home-manager.users.balsoft.home.sessionVariables // rec { - NIX_AUTO_RUN = "1"; LESS = "MR"; SYSTEMD_LESS = LESS; - DE = "generic"; }; home-manager.users.balsoft = { - xdg.enable = true; - - home.activation."mimeapps-remove" = { - before = [ "linkGeneration" ]; - after = [ ]; - data = "rm -f /home/balsoft/.config/mimeapps.list"; - }; - news.display = "silent"; - programs.command-not-found = { - enable = true; - dbPath = ../../misc/programs.sqlite; - }; - systemd.user.startServices = true; - programs.direnv.enable = true; - programs.direnv.enableNixDirenvIntegration = true; + systemd.user.startServices = true; home.stateVersion = "20.09"; }; persist.cache.directories = [ "/home/balsoft/.cache" "/var/cache" ]; - persist.state.directories = - [ "/home/balsoft/.local/share/direnv" "/var/lib/nixos" "/var/lib/systemd" ]; - - services.avahi.enable = true; + persist.state.directories = [ "/var/lib/nixos" "/var/lib/systemd" ]; system.stateVersion = "18.03"; + systemd.services.systemd-timesyncd.wantedBy = [ "multi-user.target" ]; + + systemd.timers.systemd-timesyncd = { timerConfig.OnCalendar = "hourly"; }; + + services.avahi.enable = true; } diff --git a/modules/workspace/xdg.nix b/modules/workspace/xdg.nix new file mode 100644 index 0000000..20560f8 --- /dev/null +++ b/modules/workspace/xdg.nix @@ -0,0 +1,20 @@ +{ config, pkgs, lib, ... }: { + home-manager.users.balsoft = { + xdg.enable = true; + xdg.userDirs.enable = true; + }; + + environment.sessionVariables = { + XDG_CURRENT_DESKTOP = "X-Generic"; + DE = "generic"; + }; + + persist.state.directories = map (x: "/home/balsoft/${x}") [ + "Pictures" + "Documents" + "Downloads" + "Music" + "projects" + "Videos" + ]; +} diff --git a/profiles/base.nix b/profiles/base.nix index 561596f..b901322 100644 --- a/profiles/base.nix +++ b/profiles/base.nix @@ -6,6 +6,9 @@ secrets secrets-envsubst + autoRun + xdg + devices git gpg