From 6db59aa49169c3f01cef7f8a77266d55158673f2 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Thu, 3 Feb 2022 14:00:50 -0500 Subject: [PATCH] Basic migration to home manager --- flake.lock | 39 ++++++++++++++++++-- flake.nix | 96 ++++++++++++++++++++++++++++++++++++++++++++++-- modules/user.nix | 41 --------------------- 3 files changed, 129 insertions(+), 47 deletions(-) delete mode 100644 modules/user.nix diff --git a/flake.lock b/flake.lock index c35415b..28b5e2d 100644 --- a/flake.lock +++ b/flake.lock @@ -34,6 +34,24 @@ "type": "github" } }, + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1643837728, + "narHash": "sha256-iW/5eMRQmzdctv2dAUlIaZnVWwcmaznNajS+ft1MXHg=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "9d369c75ce2fdeb296ad42bcdc8c1a523c494550", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "mozilla": { "flake": false, "locked": { @@ -83,6 +101,20 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1643472818, + "narHash": "sha256-qzVPxKDUubYIxKRSuDl/JgzXWSmGvUVYny9SxFMfPJM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7f65e4abd5ecaad12d2d26e4380d1a7d8edafea7", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1643503720, "narHash": "sha256-tJic20ufuRnG8V+fTCd3YU6xl1ImxNspoEkXHct0AG4=", @@ -98,7 +130,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1638097282, "narHash": "sha256-EXCzj9b8X/lqDPJapxZThIOKL5ASbpsJZ+8L1LnY1ig=", @@ -118,8 +150,9 @@ "inputs": { "emacs": "emacs", "fenix": "fenix", + "home-manager": "home-manager", "mozilla": "mozilla", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "nixpkgs-unstable": "nixpkgs-unstable", "sops-nix": "sops-nix" } @@ -143,7 +176,7 @@ }, "sops-nix": { "inputs": { - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_4" }, "locked": { "lastModified": 1643003126, diff --git a/flake.nix b/flake.nix index 8a848af..20272b8 100644 --- a/flake.nix +++ b/flake.nix @@ -15,18 +15,19 @@ flake = false; }; sops-nix.url = "github:Mic92/sops-nix"; + home-manager.url = "github:nix-community/home-manager"; }; - outputs = { self, nixpkgs, nixpkgs-unstable, fenix, emacs, mozilla, sops-nix }: + outputs = { self, nixpkgs, nixpkgs-unstable, fenix, emacs, mozilla, sops-nix, home-manager }: let coreModules = [ - ./modules/user.nix ./modules/common.nix ./modules/ssh.nix ./applications/utils-core.nix sops-nix.nixosModules.sops + home-manager.nixosModules.home-manager + ## Setup binary caches ({ pkgs, ... }: { - ## Setup binary caches # First install cachix, so we can discover new ones environment.systemPackages = [ pkgs.cachix ]; # Then configure up the nix community cache @@ -41,14 +42,103 @@ }) ## Setup sops ({ pkgs, config, ... }: { + # Add default secrets sops.defaultSopsFile = ./secrets/nathan.yaml; + # Use system ssh key as an age key sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; + # Load up lastfm scrobbling secret sops.secrets.lastfm-conf = { owner = "nathan"; format = "binary"; sopsFile = ./secrets/lastfm.conf; }; }) + ## Setup home manager + ({ pkgs, config, ... }: + let + unstable = import nixpkgs-unstable { + config = { allowUnfree = true; }; + overlays = [ emacs.overlay mozillaOverlay ]; + system = "x86_64-linux"; + }; + in + { + ## Some general settings that were in the user configuration + # Set time zone + time.timeZone = "America/New_York"; + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + keyMap = "us"; + }; + # enable sudo + security.sudo.enable = true; + ## Setup user first + users = { + mutableUsers = false; + users.nathan = { + isNormalUser = true; + home = "/home/nathan"; + description = "Nathan McCarty"; + extraGroups = [ "wheel" "networkmanager" "audio" "docker" "libvirtd" "uinput" "adbusers" ]; + hashedPassword = "$6$ShBAPGwzKZuB7eEv$cbb3erUqtVGFo/Vux9UwT2NkbVG9VGCxJxPiZFYL0DIc3t4GpYxjkM0M7fFnh.6V8MoSKLM/TvOtzdWbYwI58."; + }; + }; + ## Home manager proper + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.nathan = { + ## Shell + # Shell proper + programs.fish = { + enable = true; + # Use latest possible fish + package = unstable.fish; + # Setup our aliases + shellAliases = { + ls = "exa --icons"; + }; + # Custom configuration + interactiveShellInit = '' + # Setup any-nix-shell + any-nix-shell fish --info-right | source + ''; + }; + # Starship, for the prompt + programs.starship = { + enable = true; + settings = { + directory = { + truncation_length = 3; + fish_style_pwd_dir_length = 1; + }; + git_commit = { + commit_hash_length = 6; + only_detached = false; + }; + package = { + symbol = ""; + }; + time = { + disabled = false; + format = "[$time]($style)"; + time_format = "%I:%M %p"; + }; + }; + }; + }; + }; + ## Misc packages that were in user.nix + # Install general use packages + environment.systemPackages = with pkgs; [ + # Install our shell of choice + unstable.fish + # Install rclone + rclone + ]; + }) ]; desktopModules = coreModules ++ [ ./modules/audio.nix diff --git a/modules/user.nix b/modules/user.nix deleted file mode 100644 index 9cf60ad..0000000 --- a/modules/user.nix +++ /dev/null @@ -1,41 +0,0 @@ -# Contains general user environment configuration -{ config, pkgs, unstable, ... }: -{ - # Disable mutable users, force everything to go through the flake - users.mutableUsers = false; - - # Set time zone - time.timeZone = "America/New_York"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - console = { - font = "Lat2-Terminus16"; - keyMap = "us"; - }; - - # enable sudo - security.sudo.enable = true; - - # Enable fish as a login shell - environment.shells = [ pkgs.bashInteractive unstable.fish ]; - users.users.nathan = { - isNormalUser = true; - home = "/home/nathan"; - description = "Nathan McCarty"; - extraGroups = [ "wheel" "networkmanager" "audio" "docker" "libvirtd" "uinput" "adbusers" ]; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRs6zVljIlQEZ8F+aEBqqbpeFJwCw3JdveZ8TQWfkev cardno:000615938515" - ]; - shell = unstable.fish; - hashedPassword = "$6$ShBAPGwzKZuB7eEv$cbb3erUqtVGFo/Vux9UwT2NkbVG9VGCxJxPiZFYL0DIc3t4GpYxjkM0M7fFnh.6V8MoSKLM/TvOtzdWbYwI58."; - }; - - # Install general use packages - environment.systemPackages = with pkgs; [ - # Install our shell of choice - unstable.fish - # Install rclone - rclone - ]; -}