From c6100f63d7217c88b755f86628636651d6f14ddd Mon Sep 17 00:00:00 2001 From: Tyler Beckman Date: Thu, 12 Dec 2024 15:33:50 -0700 Subject: [PATCH] i did too much stuff i dont want to split this --- flake.lock | 248 ++++++++++++++++++--- flake.nix | 63 +++++- home-manager/modules/packages.nix | 2 + home-manager/modules/shell/btop.nix | 1 + home-manager/modules/shell/starship.nix | 3 +- home-manager/modules/vscode.nix | 6 +- hosts/laptop-server/default.nix | 1 + hosts/laptop-server/modules/display.nix | 3 + hosts/laptop-server/modules/networking.nix | 17 +- hosts/laptop-server/services/default.nix | 15 ++ hosts/laptop-server/services/jellyfin.nix | 17 ++ hosts/laptop/default.nix | 14 +- hosts/laptop/modules/packages.nix | 6 +- 13 files changed, 344 insertions(+), 52 deletions(-) create mode 100644 hosts/laptop-server/services/default.nix create mode 100644 hosts/laptop-server/services/jellyfin.nix diff --git a/flake.lock b/flake.lock index 1b7bcb6..09bdbb2 100755 --- a/flake.lock +++ b/flake.lock @@ -16,20 +16,42 @@ "type": "github" } }, + "colmena": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nix-github-actions": "nix-github-actions", + "nixpkgs": "nixpkgs", + "stable": "stable" + }, + "locked": { + "lastModified": 1731527002, + "narHash": "sha256-dI9I6suECoIAmbS4xcrqF8r2pbmed8WWm5LIF1yWPw8=", + "owner": "zhaofengli", + "repo": "colmena", + "rev": "e3ad42138015fcdf2524518dd564a13145c72ea1", + "type": "github" + }, + "original": { + "owner": "zhaofengli", + "repo": "colmena", + "type": "github" + } + }, "firefox-addons": { "inputs": { - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_2", "nixpkgs": [ "nixpkgs" ] }, "locked": { "dir": "/pkgs/firefox-addons", - "lastModified": 1733875367, - "narHash": "sha256-eBMHOM1KvbK8dTrM4N8ytNl8NeJF4lLyoPBRae1CqKs=", + "lastModified": 1734235408, + "narHash": "sha256-0yHVZ2+VaW36/RTGHm1x3p+KS1oAWIj+TWObLDUzHfQ=", "owner": "rycee", "repo": "nur-expressions", - "rev": "bda0131e0a7b6b5b687f5ffd8a8622054e7c444d", + "rev": "02261a5dd442b8c6eb778c31e7967e734bc2ff76", "type": "gitlab" }, "original": { @@ -42,7 +64,7 @@ "firefox-nightly": { "inputs": { "cachix": "cachix", - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "lib-aggregate": "lib-aggregate", "mozilla": "mozilla", "nixpkgs": [ @@ -50,11 +72,11 @@ ] }, "locked": { - "lastModified": 1733834155, - "narHash": "sha256-5A7EfzSmdApKmfHGtGZ4NQvMEpI/NI6VIzTNq9sUH4E=", + "lastModified": 1734312000, + "narHash": "sha256-cBvZ26RH0rFT6i2Vtv//nUrWqjJ9+0JstMiVE3KJFbQ=", "owner": "nix-community", "repo": "flake-firefox-nightly", - "rev": "f0ab3cfa3607e08169b1d87e63fe9b1e5a57f515", + "rev": "af7b83dc9687ca992bcad8c9b74485964e25c5a9", "type": "github" }, "original": { @@ -64,6 +86,22 @@ } }, "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { "locked": { "lastModified": 1717312683, "narHash": "sha256-FrlieJH50AuvagamEvWMIE6D2OAnERuDboFDYAED/dE=", @@ -78,7 +116,7 @@ "type": "github" } }, - "flake-compat_2": { + "flake-compat_3": { "flake": false, "locked": { "lastModified": 1696426674, @@ -95,6 +133,21 @@ } }, "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { "locked": { "lastModified": 1629284811, "narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=", @@ -109,7 +162,7 @@ "type": "github" } }, - "flake-utils_2": { + "flake-utils_3": { "inputs": { "systems": "systems" }, @@ -127,7 +180,7 @@ "type": "github" } }, - "flake-utils_3": { + "flake-utils_4": { "inputs": { "systems": "systems_2" }, @@ -145,6 +198,24 @@ "type": "github" } }, + "flake-utils_5": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -152,11 +223,11 @@ ] }, "locked": { - "lastModified": 1733873195, - "narHash": "sha256-dTosiZ3sZ/NKoLKQ++v8nZdEHya0eTNEsaizNp+MUPM=", + "lastModified": 1734093295, + "narHash": "sha256-hSwgGpcZtdDsk1dnzA0xj5cNaHgN9A99hRF/mxMtwS4=", "owner": "nix-community", "repo": "home-manager", - "rev": "f26aa4b76fb7606127032d33ac73d7d507d82758", + "rev": "66c5d8b62818ec4c1edb3e941f55ef78df8141a8", "type": "github" }, "original": { @@ -168,15 +239,15 @@ }, "lib-aggregate": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1733660018, - "narHash": "sha256-DHW2Hzyo8W6wVPGFaYLM9mKMH/qAtHJSUZ4ti7LHMCY=", + "lastModified": 1734264809, + "narHash": "sha256-94fu5E0gM8aMY0bX/ix7BWGf/e/OfGjoCtNrJfwL0dM=", "owner": "nix-community", "repo": "lib-aggregate", - "rev": "f710791be27b31ea1ee9c40a94d08bcbba99b3c0", + "rev": "46bedda9e45f2735f41ec3c01cba2b8ce7ba9808", "type": "github" }, "original": { @@ -201,6 +272,27 @@ "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "colmena", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1729742964, + "narHash": "sha256-B4mzTcQ0FZHdpeWcpDYPERtyjJd/NIuaQ9+BV1h+MpA=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "e04df33f62cdcf93d73e9a04142464753a16db67", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nix-index-database": { "inputs": { "nixpkgs": [ @@ -208,11 +300,11 @@ ] }, "locked": { - "lastModified": 1733629314, - "narHash": "sha256-U0vivjQFAwjNDYt49Krevs1murX9hKBFe2Ye0cHpgbU=", + "lastModified": 1734234111, + "narHash": "sha256-icEMqBt4HtGH52PU5FHidgBrNJvOfXH6VQKNtnD1aw8=", "owner": "nix-community", "repo": "nix-index-database", - "rev": "f1e477a7dd11e27e7f98b646349cd66bbabf2fb8", + "rev": "311d6cf3ad3f56cb051ffab1f480b2909b3f754d", "type": "github" }, "original": { @@ -243,11 +335,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1733759999, - "narHash": "sha256-463SNPWmz46iLzJKRzO3Q2b0Aurff3U1n0nYItxq7jU=", + "lastModified": 1730785428, + "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a73246e2eef4c6ed172979932bc80e1404ba2d56", + "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", "type": "github" }, "original": { @@ -259,11 +351,11 @@ }, "nixpkgs-24-11": { "locked": { - "lastModified": 1733550349, - "narHash": "sha256-NcGumB4Lr6KSDq+nIqXtNA8QwAQKDSZT7N9OTGWbTrs=", + "lastModified": 1734083684, + "narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e2605d0744c2417b09f8bf850dfca42fcf537d34", + "rev": "314e12ba369ccdb9b352a4db26ff419f7c49fa84", "type": "github" }, "original": { @@ -275,11 +367,11 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1733620091, - "narHash": "sha256-5WoMeCkaXqTZwwCNLRzyLxEJn8ISwjx4cNqLgqKwg9s=", + "lastModified": 1734224914, + "narHash": "sha256-hKWALzQ/RxxXdKWsLKXULru6XTag9Cc5exgVyS4a/AE=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "f4dc9a6c02e5e14d91d158522f69f6ab4194eb5b", + "rev": "538697b664a64fade8ce628d01f35d1f1fd82d77", "type": "github" }, "original": { @@ -288,6 +380,36 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1734119587, + "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1682134069, + "narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fd901ef4bf93499374c5af385b2943f5801c0833", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, "plasma-manager": { "inputs": { "home-manager": [ @@ -313,16 +435,18 @@ }, "root": { "inputs": { + "colmena": "colmena", "firefox-addons": "firefox-addons", "firefox-nightly": "firefox-nightly", "home-manager": "home-manager", "nix-index-database": "nix-index-database", "nixos-grub-themes": "nixos-grub-themes", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "nixpkgs-24-11": "nixpkgs-24-11", "plasma-manager": "plasma-manager", "sddm-sugar-candy-nix": "sddm-sugar-candy-nix", - "vscode-extensions": "vscode-extensions" + "vscode-extensions": "vscode-extensions", + "vscode-server": "vscode-server" } }, "sddm-sugar-candy-nix": { @@ -345,6 +469,22 @@ "type": "github" } }, + "stable": { + "locked": { + "lastModified": 1730883749, + "narHash": "sha256-mwrFF0vElHJP8X3pFCByJR365Q2463ATp2qGIrDUdlE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "dba414932936fde69f0606b4f1d87c5bc0003ede", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -375,20 +515,35 @@ "type": "github" } }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "vscode-extensions": { "inputs": { - "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_3", + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_4", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1733795858, - "narHash": "sha256-K595Q2PrZv2iiumdBkwM2G456T2lKsLD71bn/fbJiQ0=", + "lastModified": 1734314392, + "narHash": "sha256-EydUadS7omV3SO/4TLeMkLT2JUugvPEtvBoAF43ggWU=", "owner": "nix-community", "repo": "nix-vscode-extensions", - "rev": "66ced222ef9235f90dbdd754ede3d6476722aaa9", + "rev": "4ef033412f0732794077fcc25af4f79f097ad1e1", "type": "github" }, "original": { @@ -396,6 +551,25 @@ "repo": "nix-vscode-extensions", "type": "github" } + }, + "vscode-server": { + "inputs": { + "flake-utils": "flake-utils_5", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1729422940, + "narHash": "sha256-DlvJv33ml5UTKgu4b0HauOfFIoDx6QXtbqUF3vWeRCY=", + "owner": "nix-community", + "repo": "nixos-vscode-server", + "rev": "8b6db451de46ecf9b4ab3d01ef76e59957ff549f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-vscode-server", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 2146bb9..36daa89 100755 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,11 @@ # General NixOS config nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-24-11.url = "github:NixOS/nixpkgs/nixos-24.11"; + # Colmena unstable + colmena = { + url = "github:zhaofengli/colmena"; + # inputs.nixpkgs.follows = "nixpkgs"; + }; # Nixpkgs index for command-not-found support nix-index-database = { url = "github:nix-community/nix-index-database"; @@ -48,9 +53,11 @@ url = "github:nix-community/nix-vscode-extensions"; inputs.nixpkgs.follows = "nixpkgs"; }; + # VSCode server support + vscode-server.url = "github:nix-community/nixos-vscode-server"; }; - outputs = inputs@{ nixpkgs, home-manager, plasma-manager, nix-index-database, ... }: let + outputs = inputs@{ self, nixpkgs, home-manager, nix-index-database, vscode-server, colmena, ... }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; secrets = import ./secrets.nix; @@ -108,11 +115,63 @@ vscode.enable = false; }; } + + # VSCode server support + vscode-server.nixosModules.default + ({ pkgs, ... }: { services.vscode-server = { enable = true; nodejsPackage = pkgs.nodejs-18_x; installPath = "$HOME/.vscodium-server"; }; }) ]; specialArgs = { inherit inputs system secrets; }; }; + + colmenaHive = colmena.lib.makeHive self.outputs.colmena; + colmena = { + meta = { + nixpkgs = import nixpkgs { system = "x86_64-linux"; }; + specialArgs = { + inherit inputs secrets; + + system = "x86_64-linux"; + }; + allowApplyAll = false; + }; + + "ty-laptop-server" = { config, ... }: { + deployment = { + replaceUnknownProfiles = false; + targetUser = "root"; + targetHost = "old-lenovo-laptop"; # i should rename my tailscale devices properly + targetPort = 22; + }; + + imports = [ + ./hosts/laptop-server + + # Better command-not-found + nix-index-database.nixosModules.nix-index + { programs.nix-index-database.comma.enable = true; } + + # Home manager + home-manager.nixosModules.home-manager + ./home-manager + { + ty-home-manager-options = { + plasma.enable = false; + beets.enable = false; + firefox.enable = false; + thunderbird.enable = false; + rescrobbled.enable = false; + vscode.enable = false; + }; + } + + # VSCode server support + vscode-server.nixosModules.default + ({ pkgs, ... }: { services.vscode-server = { enable = true; nodejsPackage = pkgs.nodejs-18_x; installPath = "$HOME/.vscodium-server"; }; }) + ]; + }; + }; }; -} \ No newline at end of file +} diff --git a/home-manager/modules/packages.nix b/home-manager/modules/packages.nix index 5f3d87a..598f16a 100755 --- a/home-manager/modules/packages.nix +++ b/home-manager/modules/packages.nix @@ -24,6 +24,8 @@ # Documents logseq # Outliner libreoffice-qt6-fresh # Office-style editing + hunspell + hunspellDicts.en_US-large # Video jellyfin-media-player # Jellyfin electron client w/ MPV diff --git a/home-manager/modules/shell/btop.nix b/home-manager/modules/shell/btop.nix index bf86364..e5935dc 100644 --- a/home-manager/modules/shell/btop.nix +++ b/home-manager/modules/shell/btop.nix @@ -9,6 +9,7 @@ truecolor = true; shown_boxes = "proc cpu mem net gpu0"; update_ms = 100; + temp_scale = "fahrenheit"; }; }; } \ No newline at end of file diff --git a/home-manager/modules/shell/starship.nix b/home-manager/modules/shell/starship.nix index 6530a94..2cb855e 100644 --- a/home-manager/modules/shell/starship.nix +++ b/home-manager/modules/shell/starship.nix @@ -57,10 +57,9 @@ hostname = { disabled = false; ssh_only = false; - ssh_symbol = "🌐 "; trim_at = ""; style = "bg:prev_bg fg:prev_fg"; - format = "[$ssh_symbol$hostname]($style)"; + format = "[$hostname]($style)"; }; shell = { diff --git a/home-manager/modules/vscode.nix b/home-manager/modules/vscode.nix index 778b49a..7ce274f 100644 --- a/home-manager/modules/vscode.nix +++ b/home-manager/modules/vscode.nix @@ -23,7 +23,7 @@ # Language support rust-lang.rust-analyzer # Rust llvm-vs-code-extensions.vscode-clangd # C++ - vadimcn.vscode-lldb # C++ Debugging + # vadimcn.vscode-lldb # C++ Debugging jnoortheen.nix-ide # Nix tamasfe.even-better-toml # TOML yzhang.markdown-all-in-one # Markdown @@ -43,7 +43,9 @@ yy0931.save-as-root # Save as root over SSH akiramiyakoda.cppincludeguard # Auto-insert header guards for header files ]) - ); + ) ++ (with pkgs.vscode-extensions; [ + vadimcn.vscode-lldb + ]); userSettings = { # Editor diff --git a/hosts/laptop-server/default.nix b/hosts/laptop-server/default.nix index 3fb21a3..3daba20 100644 --- a/hosts/laptop-server/default.nix +++ b/hosts/laptop-server/default.nix @@ -10,6 +10,7 @@ imports = [ ./hardware-configuration.nix ./modules + ./services ]; system.stateVersion = "24.11"; diff --git a/hosts/laptop-server/modules/display.nix b/hosts/laptop-server/modules/display.nix index 1782bcc..43372b8 100644 --- a/hosts/laptop-server/modules/display.nix +++ b/hosts/laptop-server/modules/display.nix @@ -18,4 +18,7 @@ } ]; }; + + # Disable sleep on lid close (because server) + services.logind.lidSwitch = "ignore"; } diff --git a/hosts/laptop-server/modules/networking.nix b/hosts/laptop-server/modules/networking.nix index b99611a..21dc5d8 100644 --- a/hosts/laptop-server/modules/networking.nix +++ b/hosts/laptop-server/modules/networking.nix @@ -1,12 +1,17 @@ { ... }: { - networking.hostName = "ty-laptop-server"; + networking = { + hostName = "ty-laptop-server"; - # Enable firewall - networking.firewall.enable = true; - - # Enable NetworkManager - networking.networkmanager.enable = true; + # Enable firewall + firewall = { + enable = true; + trustedInterfaces = [ "lo" "ve-jellyfin" ]; + }; + + # Enable NetworkManager + networkmanager.enable = true; + }; # Tailscale overlay network configuration services.tailscale = { diff --git a/hosts/laptop-server/services/default.nix b/hosts/laptop-server/services/default.nix new file mode 100644 index 0000000..beda8a2 --- /dev/null +++ b/hosts/laptop-server/services/default.nix @@ -0,0 +1,15 @@ +{ ... }: +{ + imports = [ + ./jellyfin.nix + ]; + + networking = { + nat = { + enable = true; + internalInterfaces = ["ve-jellyfin"]; + externalInterface = "wlp2s0"; + }; + networkmanager.unmanaged = [ "interface-name:ve-jellyfin" ]; + }; +} \ No newline at end of file diff --git a/hosts/laptop-server/services/jellyfin.nix b/hosts/laptop-server/services/jellyfin.nix new file mode 100644 index 0000000..7b24fb0 --- /dev/null +++ b/hosts/laptop-server/services/jellyfin.nix @@ -0,0 +1,17 @@ +{ config, ... }: +{ + containers.jellyfin = { + config = { pkgs, ...}: { + system.stateVersion = "25.05"; + + services.jellyfin = { + enable = true; + package = pkgs.jellyfin; + }; + }; + autoStart = true; + privateNetwork = true; + hostAddress = "172.30.0.2"; # TODO define in config option + localAddress = "172.30.0.2"; + }; +} \ No newline at end of file diff --git a/hosts/laptop/default.nix b/hosts/laptop/default.nix index 7be3629..51090fa 100644 --- a/hosts/laptop/default.nix +++ b/hosts/laptop/default.nix @@ -7,6 +7,18 @@ system.stateVersion = "24.05"; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; + nix.settings = { + experimental-features = [ "nix-command" "flakes" ]; + + substituters = [ + "https://colmena.cachix.org" + ]; + trusted-public-keys = [ + "colmena.cachix.org-1:7BzpDnjjH8ki2CT3f6GdOk7QAzPOl+1t3LvTLXqYcSg=" + ]; + + auto-optimise-store = true; + }; + nix.gc.automatic = true; } \ No newline at end of file diff --git a/hosts/laptop/modules/packages.nix b/hosts/laptop/modules/packages.nix index 2c68500..7cab9b4 100644 --- a/hosts/laptop/modules/packages.nix +++ b/hosts/laptop/modules/packages.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, ... }: +{ pkgs, inputs, system, ... }: { # Install system packages environment.systemPackages = with pkgs; [ @@ -6,8 +6,10 @@ wget curl neovim - home-manager wl-clipboard-rs + # Nix utilities + home-manager + inputs.colmena.packages."${system}".colmena # VCS git jujutsu