From d7795d2481d8b3847690bb9e80a25f1b0c53bac2 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Fri, 1 Sep 2023 03:34:54 +0000 Subject: [PATCH] feat: dragonwell Signed-off-by: jolheiser --- apps/common.nix | 46 +++++++++++++++++++++++++++ apps/default.nix | 40 ++---------------------- flake.nix | 52 +++++++++++++++++++++---------- machines/dragonwell/default.nix | 53 ++++++++++++++++++++++++++++++++ machines/dragonwell/hardware.nix | 10 ++++++ 5 files changed, 147 insertions(+), 54 deletions(-) create mode 100644 apps/common.nix create mode 100644 machines/dragonwell/default.nix create mode 100644 machines/dragonwell/hardware.nix diff --git a/apps/common.nix b/apps/common.nix new file mode 100644 index 0000000..aa971bd --- /dev/null +++ b/apps/common.nix @@ -0,0 +1,46 @@ +{ + pkgs, + config, + ... +}: { + imports = [ + ./bat.nix + ./bottom.nix + ./exa.nix + ./fzf.nix + ./gpg.nix + ./git.nix + ./helix.nix + ./jq.nix + ./lazygit.nix + ./nushell.nix + ./oh-my-posh.nix + ./ssh.nix + ./xdg.nix + ./zoxide.nix + ]; + home = { + packages = with pkgs; [ + # Tools + age + bitwarden-cli + duf + du-dust + fd + just + ripgrep + + # LSPs + nil + + # Formatters + alejandra + ]; + activation.report-changes = config.lib.dag.entryAnywhere '' + ${pkgs.nvd}/bin/nvd --nix-bin-dir=${pkgs.nix}/bin diff $oldGenPath $newGenPath + ''; + stateVersion = "22.11"; + }; + + programs = {home-manager.enable = true;}; +} diff --git a/apps/default.nix b/apps/default.nix index 35a50ec..08c7d47 100644 --- a/apps/default.nix +++ b/apps/default.nix @@ -1,58 +1,30 @@ -{ - pkgs, - config, - ... -}: { +{pkgs, ...}: { imports = [ - ./bat.nix - ./bottom.nix - ./exa.nix + ./common.nix + ./firefox.nix - ./fzf.nix - ./gpg.nix - ./git.nix ./go.nix ./gtk.nix - ./helix.nix - ./jq.nix - ./lazygit.nix - ./nushell.nix - ./oh-my-posh.nix ./spotifyd.nix - ./ssh.nix ./tiny.nix ./wezterm.nix - ./xdg.nix - ./zoxide.nix ]; home = { packages = with pkgs; [ # Tools - age - bitwarden-cli delve discord - duf - du-dust - fd - just obsidian spotify-tui - ripgrep - usql # LSPs gopls lua-language-server marksman - nil nodePackages.yaml-language-server # Formatters alejandra - black - gofumpt - nodePackages.lua-fmt # IDEs jetbrains.goland @@ -65,11 +37,5 @@ nur.repos.jolheiser.tclip nur.repos.jolheiser.tmpl ]; - activation.report-changes = config.lib.dag.entryAnywhere '' - ${pkgs.nvd}/bin/nvd --nix-bin-dir=${pkgs.nix}/bin diff $oldGenPath $newGenPath - ''; - stateVersion = "22.11"; }; - - programs = {home-manager.enable = true;}; } diff --git a/flake.nix b/flake.nix index 6b4d8eb..8d631b9 100644 --- a/flake.nix +++ b/flake.nix @@ -36,7 +36,7 @@ }; }; }; - commonConfig = { + commonConfig = {server ? false}: { config, pkgs, ... @@ -46,23 +46,33 @@ owner = username; }; in { - config = { - nixpkgs.overlays = [overlays]; - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users.${username}.imports = [./apps]; - extraSpecialArgs = { - flakePath = "/home/${username}/.config/nixpkgs"; + config = + { + nixpkgs.overlays = [overlays]; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.${username}.imports = + if !server + then [./apps] + else [./apps/common.nix]; + extraSpecialArgs = { + flakePath = "/home/${username}/.config/nixpkgs"; + }; }; - }; - age.secrets = { - ssh-config = userSecret ./secrets/shared/ssh-config.age; - ssh-config-work = userSecret ./secrets/shared/ssh-config-work.age; - spotify-pw = userSecret ./secrets/shared/spotify-pw.age; - irc-pw = userSecret ./secrets/shared/irc-pw.age; - }; - }; + } + // ( + if !server + then { + age.secrets = { + ssh-config = userSecret ./secrets/shared/ssh-config.age; + ssh-config-work = userSecret ./secrets/shared/ssh-config-work.age; + spotify-pw = userSecret ./secrets/shared/spotify-pw.age; + irc-pw = userSecret ./secrets/shared/irc-pw.age; + }; + } + else {} + ); }; username = "jolheiser"; in @@ -113,6 +123,14 @@ commonConfig ]; }; + "dragonwell" = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + home-manager.nixosModules.home-manager + ./machines/dragonwell + (commonConfig {server = true;}) + ]; + }; }; } // inputs.flake-utils.lib.eachDefaultSystem (system: let diff --git a/machines/dragonwell/default.nix b/machines/dragonwell/default.nix new file mode 100644 index 0000000..589e707 --- /dev/null +++ b/machines/dragonwell/default.nix @@ -0,0 +1,53 @@ +{pkgs, ...}: let + username = "jolheiser"; +in { + imports = [./hardware.nix]; + + nixpkgs.config.allowUnfree = true; + + nix = { + gc.automatic = true; + package = pkgs.nixVersions.nix_2_15; + settings = { + experimental-features = ["flakes" "nix-command" "repl-flake"]; + auto-optimise-store = true; + warn-dirty = false; + }; + }; + + system.activationScripts.diff = { + supportsDryActivation = true; + text = '' + ${pkgs.nvd}/bin/nvd --nix-bin-dir=${pkgs.nix}/bin diff /run/current-system "$systemConfig" + ''; + }; + + boot.tmp.cleanOnBoot = true; + zramSwap.enable = true; + + networking = { + hostName = "dragonwell"; + + firewall.enable = true; + }; + + services = { + openssh = { + enable = true; + }; + + tailscale.enable = true; + }; + + virtualisation.docker.enable = true; + + users.users."${username}" = { + extraGroups = ["wheel" "docker" "storage"]; + isNormalUser = true; + openssh.authorizedKeys.keys = [ + ''ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfKqCWtDlS3tgvfT6hQN+ii8UtabIZ+ZNmYN+bLwIa8PHOEW5MbfaqXSlhKkSi4+7SfQDCHphw0SMfhsQ4qMEcoywZ+4niDgKlQEVkl+S/VGbLuPe92NRStkyreZBLPr3Rh7ScNlGHcmHmoV9v7725fMnsMmabGVhpGO84PwNHOfJyv2tx2h6LxFbAV8S44UQu2lc8YLWCK2UvKuRnBerBXLnDQThUUX8UuCFzb786gQzD5XDU0MENbByxiy0XdVGAC+tFXEiSIgFZlFbFYyShgdTP9MzX2MOglEi+ae+1UIFncraW7ptUey7qHFJylpHWWWvE+GTwsg2G50i0FvFj jolheiser@jolheiser'' + ]; + }; + + system.stateVersion = "22.11"; +} diff --git a/machines/dragonwell/hardware.nix b/machines/dragonwell/hardware.nix new file mode 100644 index 0000000..329ed8a --- /dev/null +++ b/machines/dragonwell/hardware.nix @@ -0,0 +1,10 @@ +{modulesPath, ...}: { + imports = [(modulesPath + "/profiles/qemu-guest.nix")]; + boot.loader.grub.device = "/dev/sda"; + boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi"]; + boot.initrd.kernelModules = ["nvme"]; + fileSystems."/" = { + device = "/dev/sda1"; + fsType = "ext4"; + }; +}