From 04871258ee4233cb29d9662eb8ba6eb2de9d3197 Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Fri, 4 Oct 2024 01:01:41 +0200 Subject: [PATCH] moved ester and eve over to home manager --- README.md | 2 +- enviroments/common/default.nix | 3 ++ hosts/defiant/configuration.nix | 2 +- hosts/horizon/configuration.nix | 17 +++++--- hosts/twilight/configuration.nix | 19 ++++---- users/default.nix | 1 - users/ester/default.nix | 16 ++----- users/ester/home.nix | 73 +++++++++++++++++++++++++++++++ users/eve/default.nix | 18 ++------ users/eve/home.nix | 75 ++++++++++++++++++++++++++++++++ users/home.nix | 4 +- users/leyla/default.nix | 22 +++++----- users/leyla/home.nix | 29 ++---------- users/leyla/packages.nix | 4 +- users/leyla/vscode.nix | 67 ++++++++++++++-------------- 15 files changed, 233 insertions(+), 119 deletions(-) create mode 100644 users/ester/home.nix create mode 100644 users/eve/home.nix diff --git a/README.md b/README.md index 8e7e794..677971c 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,8 @@ to update passwords run: `nix shell nixpkgs#sops -c sops secrets/user-passwords. - join config for systemd.tmpfiles.rules and service directory bindings - monitor configuration in `~/.config/monitors.xml` should be sym linked to `/run/gdm/.config/monitors.xml` (https://www.reddit.com/r/NixOS/comments/u09cz9/home_manager_create_my_own_symlinks_automatically/) - move applications in server environment into their own flakes -- Eve and Ester home-manager - get rid of disko config and import it in hardware-configuration.nix +- why does users.users..home conflict with home-manager.users..home.homeDirectory ## New Features - offline access for nfs mounts (overlay with rsync might be a good option here? https://www.spinics.net/lists/linux-unionfs/msg07105.html note about nfs4 and overlay fs) - Flake templates diff --git a/enviroments/common/default.nix b/enviroments/common/default.nix index 9ee0c50..3416c1a 100644 --- a/enviroments/common/default.nix +++ b/enviroments/common/default.nix @@ -42,18 +42,21 @@ uid = 1000; description = "Leyla"; group = "leyla"; + home = "/home/leyla"; }; ester = { uid = 1001; description = "Ester"; group = "ester"; + home = "/home/ester"; }; eve = { uid = 1002; description = "Eve"; group = "eve"; + home = "/home/eve"; }; jellyfin = { diff --git a/hosts/defiant/configuration.nix b/hosts/defiant/configuration.nix index 09c51a4..bbe9601 100644 --- a/hosts/defiant/configuration.nix +++ b/hosts/defiant/configuration.nix @@ -15,7 +15,7 @@ ]; home-manager.users.leyla.config = { - isThinUser = true; + isTerminalUser = true; }; boot.loader.grub = { diff --git a/hosts/horizon/configuration.nix b/hosts/horizon/configuration.nix index 7086276..ef042d6 100644 --- a/hosts/horizon/configuration.nix +++ b/hosts/horizon/configuration.nix @@ -14,13 +14,16 @@ ../../enviroments/client ]; - home-manager.users.leyla.config = { - isFullUser = true; - }; - - users = { - ester.isFullUser = true; - eve.isFullUser = true; + home-manager.users = { + leyla.config = { + isDesktopUser = true; + }; + ester.config = { + isDesktopUser = true; + }; + eve.config = { + isDesktopUser = true; + }; }; # enabled virtualisation for docker diff --git a/hosts/twilight/configuration.nix b/hosts/twilight/configuration.nix index 39bf38b..4de1e5f 100644 --- a/hosts/twilight/configuration.nix +++ b/hosts/twilight/configuration.nix @@ -14,14 +14,17 @@ ../../enviroments/client ]; - home-manager.users.leyla.config = { - isFullUser = true; - hasGPU = true; - }; - - users = { - ester.isFullUser = true; - eve.isFullUser = true; + home-manager.users = { + leyla.config = { + isDesktopUser = true; + hasGPU = true; + }; + ester.config = { + isDesktopUser = true; + }; + eve.config = { + isDesktopUser = true; + }; }; systemd.tmpfiles.rules = [ diff --git a/users/default.nix b/users/default.nix index 3dc52d9..ab74274 100644 --- a/users/default.nix +++ b/users/default.nix @@ -3,6 +3,5 @@ users.mutableUsers = false; - home-manager.extraSpecialArgs = {inherit inputs;}; home-manager.users = import ./home.nix; } diff --git a/users/ester/default.nix b/users/ester/default.nix index f6a1203..61e0d4e 100644 --- a/users/ester/default.nix +++ b/users/ester/default.nix @@ -5,16 +5,12 @@ inputs, ... }: let - cfg = config.users.ester; + cfg = config.home-manager.users.ester; in { - options.users.ester = { - isFullUser = lib.mkEnableOption "ester"; - }; - config = { nixpkgs.config.allowUnfree = true; - sops.secrets = lib.mkIf cfg.isFullUser { + sops.secrets = lib.mkIf cfg.isDesktopUser { "passwords/ester" = { neededForUsers = true; sopsFile = "${inputs.secrets}/user-passwords.yaml"; @@ -22,18 +18,12 @@ in { }; users.users.ester = ( - if cfg.isFullUser + if cfg.isDesktopUser then { isNormalUser = true; extraGroups = ["networkmanager"]; hashedPasswordFile = config.sops.secrets."passwords/ester".path; - - packages = with pkgs; [ - firefox - bitwarden - discord - ]; } else { isSystemUser = true; diff --git a/users/ester/home.nix b/users/ester/home.nix new file mode 100644 index 0000000..1d3a2a2 --- /dev/null +++ b/users/ester/home.nix @@ -0,0 +1,73 @@ +{ + pkgs, + lib, + config, + ... +}: { + options = { + isDesktopUser = lib.mkEnableOption "install applications intended for desktop use"; + }; + + config = { + home = { + username = "ester"; + homeDirectory = "/home/ester"; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + stateVersion = "23.11"; # Please read the comment before changing. + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. If you don't want to manage your shell through Home + # Manager then you have to manually source 'hm-session-vars.sh' located at + # either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/ester/etc/profile.d/hm-session-vars.sh + # + sessionVariables = { + # EDITOR = "emacs"; + }; + + packages = lib.mkIf config.isDesktopUser ( + with pkgs; [ + firefox + bitwarden + discord + ] + ); + }; + + programs = { + # Let Home Manager install and manage itself. + home-manager.enable = true; + }; + }; +} diff --git a/users/eve/default.nix b/users/eve/default.nix index 7902ff2..4956dea 100644 --- a/users/eve/default.nix +++ b/users/eve/default.nix @@ -5,16 +5,12 @@ inputs, ... }: let - cfg = config.users.eve; + cfg = config.home-manager.users.eve; in { - options.users.eve = { - isFullUser = lib.mkEnableOption "eve"; - }; - config = { nixpkgs.config.allowUnfree = true; - sops.secrets = lib.mkIf cfg.isFullUser { + sops.secrets = lib.mkIf cfg.isDesktopUser { "passwords/eve" = { neededForUsers = true; sopsFile = "${inputs.secrets}/user-passwords.yaml"; @@ -22,20 +18,12 @@ in { }; users.users.eve = ( - if cfg.isFullUser + if cfg.isDesktopUser then { isNormalUser = true; extraGroups = ["networkmanager"]; hashedPasswordFile = config.sops.secrets."passwords/eve".path; - - packages = with pkgs; [ - firefox - bitwarden - discord - makemkv - signal-desktop - ]; } else { isSystemUser = true; diff --git a/users/eve/home.nix b/users/eve/home.nix new file mode 100644 index 0000000..461458d --- /dev/null +++ b/users/eve/home.nix @@ -0,0 +1,75 @@ +{ + pkgs, + lib, + config, + ... +}: { + options = { + isDesktopUser = lib.mkEnableOption "install applications intended for desktop use"; + }; + + config = { + home = { + username = "eve"; + homeDirectory = "/home/eve"; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + stateVersion = "23.11"; # Please read the comment before changing. + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. If you don't want to manage your shell through Home + # Manager then you have to manually source 'hm-session-vars.sh' located at + # either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/leyla/etc/profile.d/hm-session-vars.sh + # + sessionVariables = { + # EDITOR = "emacs"; + }; + + packages = lib.mkIf config.isDesktopUser ( + with pkgs; [ + firefox + bitwarden + discord + makemkv + signal-desktop + ] + ); + }; + + programs = { + # Let Home Manager install and manage itself. + home-manager.enable = true; + }; + }; +} diff --git a/users/home.nix b/users/home.nix index 0571905..88d6337 100644 --- a/users/home.nix +++ b/users/home.nix @@ -1,5 +1,5 @@ { leyla = import ./leyla/home.nix; - # ester = import ./ester/home.nix; - # eve = import ./eve/home.nix; + ester = import ./ester/home.nix; + eve = import ./eve/home.nix; } diff --git a/users/leyla/default.nix b/users/leyla/default.nix index 47b3edb..e8baee3 100644 --- a/users/leyla/default.nix +++ b/users/leyla/default.nix @@ -9,7 +9,7 @@ in { config = { nixpkgs.config.allowUnfree = true; - sops.secrets = lib.mkIf (cfg.isFullUser || cfg.isThinUser) { + sops.secrets = lib.mkIf (cfg.isDesktopUser || cfg.isTerminalUser) { "passwords/leyla" = { neededForUsers = true; sopsFile = "${inputs.secrets}/user-passwords.yaml"; @@ -17,15 +17,13 @@ in { }; users.users.leyla = ( - if (cfg.isFullUser || cfg.isThinUser) + if (cfg.isDesktopUser || cfg.isTerminalUser) then { isNormalUser = true; - extraGroups = lib.mkMerge [ + extraGroups = ( ["networkmanager" "wheel"] - ( - lib.mkUnless cfg.isThinUser ["adbusers"] - ) - ]; + ++ lib.lists.optional (!cfg.isTerminalUser) "adbusers" + ); hashedPasswordFile = config.sops.secrets."passwords/leyla".path; @@ -43,8 +41,8 @@ in { services = { ollama = { - enable = true; - acceleration = lib.mkIf cfg.hasGPU "cuda"; + enable = cfg.hasGPU; + acceleration = "cuda"; }; # TODO: this should reference the home directory from the user config @@ -59,16 +57,16 @@ in { }; programs = { - steam = lib.mkIf cfg.isFullUser { + steam = lib.mkIf cfg.isDesktopUser { enable = true; remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated ServerServer localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers }; - noisetorch.enable = cfg.isFullUser; + noisetorch.enable = cfg.isDesktopUser; - adb.enable = cfg.isFullUser; + adb.enable = cfg.isDesktopUser; }; }; } diff --git a/users/leyla/home.nix b/users/leyla/home.nix index f8d4c42..ac513de 100644 --- a/users/leyla/home.nix +++ b/users/leyla/home.nix @@ -9,8 +9,8 @@ ]; options = { - isFullUser = lib.mkEnableOption "create usable leyla user"; - isThinUser = lib.mkEnableOption "create usable user but witohut user applications"; + isDesktopUser = lib.mkEnableOption "install applications intended for desktop use"; + isTerminalUser = lib.mkEnableOption "install applications intended for terminal use"; hasGPU = lib.mkEnableOption "installs gpu intensive programs"; }; @@ -30,27 +30,6 @@ # release notes. stateVersion = "23.11"; # Please read the comment before changing. - # The home.packages option allows you to install Nix packages into your - # environment. - packages = [ - # # Adds the 'hello' command to your environment. It prints a friendly - # # "Hello, world!" when run. - # pkgs.hello - - # # It is sometimes useful to fine-tune packages, for example, by applying - # # overrides. You can do that directly here, just don't forget the - # # parentheses. Maybe you want to install Nerd Fonts with a limited number of - # # fonts? - # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) - - # # You can also create simple shell scripts directly inside your - # # configuration. For example, this adds a command 'my-hello' to your - # # environment: - # (pkgs.writeShellScriptBin "my-hello" '' - # echo "Hello, ${config.home.username}!" - # '') - ]; - # Home Manager is pretty good at managing dotfiles. The primary way to manage # plain files is through 'home.file'. file = { @@ -101,10 +80,10 @@ # add direnv to auto load flakes for development direnv = { enable = true; - enableBashIntegration = true; # see note on other shells below + enableBashIntegration = true; nix-direnv.enable = true; }; - bash.enable = true; # see note on other shells below + bash.enable = true; # firefox = { # enable = true; diff --git a/users/leyla/packages.nix b/users/leyla/packages.nix index 1478d1d..d59696d 100644 --- a/users/leyla/packages.nix +++ b/users/leyla/packages.nix @@ -11,7 +11,7 @@ ]; home = { - packages = lib.mkIf (config.isFullUser || config.isThinUser) ( + packages = lib.mkIf (config.isDesktopUser || config.isTerminalUser) ( lib.mkMerge [ ( with pkgs; [ @@ -22,7 +22,7 @@ ] ) ( - lib.mkIf (!config.isThinUser) ( + lib.mkIf (!config.isTerminalUser) ( with pkgs; [ #foss platforms signal-desktop diff --git a/users/leyla/vscode.nix b/users/leyla/vscode.nix index 37fc4be..dbb5ae0 100644 --- a/users/leyla/vscode.nix +++ b/users/leyla/vscode.nix @@ -12,7 +12,7 @@ }; programs = { - bash.shellAliases = lib.mkIf config.isFullUser { + bash.shellAliases = lib.mkIf config.isDesktopUser { code = "codium"; }; @@ -36,42 +36,45 @@ ]; }; - extensions = with extensions.open-vsx; - [ - # vs code feel extensions - ms-vscode.atom-keybindings - akamud.vscode-theme-onedark - streetsidesoftware.code-spell-checker - streetsidesoftware.code-spell-checker-german - streetsidesoftware.code-spell-checker-italian - jeanp413.open-remote-ssh + extensions = ( + with extensions.open-vsx; + [ + # vs code feel extensions + ms-vscode.atom-keybindings + akamud.vscode-theme-onedark + streetsidesoftware.code-spell-checker + streetsidesoftware.code-spell-checker-german + streetsidesoftware.code-spell-checker-italian + jeanp413.open-remote-ssh - # nix extensions - pinage404.nix-extension-pack - jnoortheen.nix-ide + # nix extensions + pinage404.nix-extension-pack + jnoortheen.nix-ide - # html extensions - formulahendry.auto-rename-tag - ms-vscode.live-server + # html extensions + formulahendry.auto-rename-tag + ms-vscode.live-server - # js extensions - dsznajder.es7-react-js-snippets - dbaeumer.vscode-eslint - standard.vscode-standard - firsttris.vscode-jest-runner - stylelint.vscode-stylelint - tauri-apps.tauri-vscode + # js extensions + dsznajder.es7-react-js-snippets + dbaeumer.vscode-eslint + standard.vscode-standard + firsttris.vscode-jest-runner + stylelint.vscode-stylelint + tauri-apps.tauri-vscode - # misc extensions - bungcip.better-toml + # misc extensions + bungcip.better-toml - # the number at the start of the name here doesnt resolve nicely so we have to refernce it as a part of open-vsx directly instead of though with - open-vsx."10nates".ollama-autocoder - ] - ++ (with extensions.vscode-marketplace; [ - # js extensions - karyfoundation.nearley - ]); + open-vsx."10nates".ollama-autocoder + ] + ++ ( + with extensions.vscode-marketplace; [ + # js extensions + karyfoundation.nearley + ] + ) + ); }; }; }