diff --git a/.gitignore b/.gitignore index ec5c72c..9934212 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ home/dots/qtile/.direnv +mullvad/inactive diff --git a/flake.lock b/flake.lock index 6f64fb8..80f99f6 100644 --- a/flake.lock +++ b/flake.lock @@ -124,6 +124,24 @@ "inputs": { "systems": "systems_2" }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, "locked": { "lastModified": 1681202837, "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", @@ -138,6 +156,21 @@ "type": "github" } }, + "flakey-profile": { + "locked": { + "lastModified": 1712898590, + "narHash": "sha256-FhGIEU93VHAChKEXx905TSiPZKga69bWl1VB37FK//I=", + "owner": "lf-", + "repo": "flakey-profile", + "rev": "243c903fd8eadc0f63d205665a92d4df91d42d9d", + "type": "github" + }, + "original": { + "owner": "lf-", + "repo": "flakey-profile", + "type": "github" + } + }, "flatpaks": { "locked": { "lastModified": 1721549352, @@ -183,11 +216,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1723549983, - "narHash": "sha256-8lya0y9tR3dtVk++nUjVaPbSb5+Ah+vKgcX+3R556BQ=", + "lastModified": 1723657484, + "narHash": "sha256-oSxczvhDKCc/ilTPiMz46RmTLhyBoVxhGWhp7Ee54eA=", "owner": "helix-editor", "repo": "helix", - "rev": "f65ec32a1c2e09b3b32b521617f4a3ef19bc71c5", + "rev": "ff33b07756548935577aefc15cf48a1beb27b162", "type": "github" }, "original": { @@ -203,11 +236,11 @@ ] }, "locked": { - "lastModified": 1723535926, - "narHash": "sha256-XCQ/IGVRwhM0m2jDYkTKySEKpdI5mRcrFCkEhkn2+K4=", + "lastModified": 1723621879, + "narHash": "sha256-7/VysfDaFfmFJ7zgt2H8J04PkSO2bMjoN7e0wwUu6Ek=", "owner": "n-hass", "repo": "home-manager", - "rev": "db192f855b550c5e5cb25cef7d41be2081b32a3f", + "rev": "639ab4410badd2a7a4c28b678452e1dc2d30450a", "type": "github" }, "original": { @@ -233,6 +266,43 @@ "type": "github" } }, + "lix": { + "flake": false, + "locked": { + "lastModified": 1723577950, + "narHash": "sha256-kOpGI9WPmte1L4QWHviuXsr8jxmGn27zwi82jtzYObM=", + "rev": "b016eb0895bb6714a4f6530d9a2bb6577ac6c3cf", + "type": "tarball", + "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/b016eb0895bb6714a4f6530d9a2bb6577ac6c3cf.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://git.lix.systems/lix-project/lix/archive/main.tar.gz" + } + }, + "lix-module": { + "inputs": { + "flake-utils": "flake-utils_2", + "flakey-profile": "flakey-profile", + "lix": [ + "lix" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723511483, + "narHash": "sha256-rT/OkVXKkns2YvyF1nFvl+8Gc3sld1c1sXPtGkbqaDY=", + "rev": "cecf70b77539c1a593f60ec9d0305b5e537ab6a9", + "type": "tarball", + "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/cecf70b77539c1a593f60ec9d0305b5e537ab6a9.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz" + } + }, "madness": { "locked": { "lastModified": 1720637547, @@ -269,7 +339,7 @@ "nix-rice": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "kitty-themes-src": "kitty-themes-src", "nixpkgs-lib": "nixpkgs-lib", "pre-commit-hooks": "pre-commit-hooks" @@ -317,11 +387,11 @@ "rust-overlay": "rust-overlay_2" }, "locked": { - "lastModified": 1723512951, - "narHash": "sha256-XZMqVka80UyX9JB6qnsb8TVERWgHSaKo0IAw9rFTTIU=", + "lastModified": 1723599342, + "narHash": "sha256-4eUNZxze/tMkKzfAJSS+o3o4LcMH1znWfCUICO/Sw4A=", "owner": "lilyinstarlight", "repo": "nixos-cosmic", - "rev": "c2e0c9b3ef4ed20ea59031c6187b408d560cf874", + "rev": "5e861c29989be12691f90bda3a7b97891a629ed3", "type": "github" }, "original": { @@ -397,11 +467,11 @@ }, "nixpkgs-stable_2": { "locked": { - "lastModified": 1723282977, - "narHash": "sha256-oTK91aOlA/4IsjNAZGMEBz7Sq1zBS0Ltu4/nIQdYDOg=", + "lastModified": 1723556749, + "narHash": "sha256-+CHVZnTnIYRLYsARInHYoWkujzcRkLY/gXm3s5bE52o=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a781ff33ae258bbcfd4ed6e673860c3e923bf2cc", + "rev": "4a92571f9207810b559c9eac203d1f4d79830073", "type": "github" }, "original": { @@ -461,11 +531,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1723175592, - "narHash": "sha256-M0xJ3FbDUc4fRZ84dPGx5VvgFsOzds77KiBMW/mMTnI=", + "lastModified": 1723362943, + "narHash": "sha256-dFZRVSgmJkyM0bkPpaYRtG/kRMRTorUIDj8BxoOt1T4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5e0ca22929f3342b19569b21b2f3462f053e497b", + "rev": "a58bc8ad779655e790115244571758e8de055e3d", "type": "github" }, "original": { @@ -477,11 +547,11 @@ }, "nur": { "locked": { - "lastModified": 1723554177, - "narHash": "sha256-c874Bx8Hi6NGEt+PZQ88tgay2eyZ9Zly6rDHFhKFRJk=", + "lastModified": 1723664702, + "narHash": "sha256-ErRJ3oUHFOzUXoDAzws/h5u7c6dCExETjmm5uIFL/QY=", "owner": "nix-community", "repo": "NUR", - "rev": "494fb37109715b5e3498c6a85532d5be16bdf10e", + "rev": "7bcbb0362c92f230ba4a2c5ad227e04f84fc1ce0", "type": "github" }, "original": { @@ -520,6 +590,8 @@ "flatpaks": "flatpaks", "helix": "helix", "home-manager": "home-manager", + "lix": "lix", + "lix-module": "lix-module", "madness": "madness", "nix-index-database": "nix-index-database", "nix-rice": "nix-rice", @@ -530,7 +602,10 @@ "nixpkgs" ], "nur": "nur", - "rust-overlay": "rust-overlay_3" + "rust-overlay": [ + "nixos-cosmic", + "rust-overlay" + ] } }, "rust-overlay": { @@ -565,26 +640,6 @@ "nixpkgs" ] }, - "locked": { - "lastModified": 1723429325, - "narHash": "sha256-4x/32xTCd+xCwFoI/kKSiCr5LQA2ZlyTRYXKEni5HR8=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "65e3dc0fe079fe8df087cd38f1fe6836a0373aad", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "rust-overlay_3": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, "locked": { "lastModified": 1723515680, "narHash": "sha256-nHdKymsHCVIh0Wdm4MvSgxcTTg34FJIYHRQkQYaSuvk=", @@ -629,6 +684,21 @@ "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" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index b78c2fa..1f43633 100644 --- a/flake.nix +++ b/flake.nix @@ -7,10 +7,11 @@ nur.url = "github:/nix-community/NUR"; - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + # rust-overlay = { + # url = "github:oxalica/rust-overlay"; + # inputs.nixpkgs.follows = "nixpkgs"; + # }; + rust-overlay.follows = "nixos-cosmic/rust-overlay"; helix.url = "github:helix-editor/helix"; @@ -28,11 +29,20 @@ flatpaks.url = "github:gmodena/nix-flatpak"; - nixos-cosmic = { - url = "github:lilyinstarlight/nixos-cosmic"; - }; + nixos-cosmic.url = "github:lilyinstarlight/nixos-cosmic"; madness.url = "github:antithesishq/madness"; + + lix = { + url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz"; + flake = false; + }; + + lix-module = { + url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.lix.follows = "lix"; + }; }; outputs = { @@ -44,62 +54,57 @@ flatpaks, nix-index-database, madness, + lix, + lix-module, ... } @ inputs: let inherit (self) outputs; + inherit (nixpkgs) lib; + inherit (lib) mapAttrs; sharedModules = [ + lix-module.nixosModules.default madness.nixosModules.madness nur.nixosModules.nur nix-index-database.nixosModules.nix-index + nixos-cosmic.nixosModules.default ./system/cachix.nix ]; system = "x86_64-linux"; + createSystems = definitions: + mapAttrs (name: info: + nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = {inherit inputs outputs;}; + modules = + [ + ./system/${name}.nix + home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + extraSpecialArgs = {inherit inputs outputs;}; + users.${info.user}.imports = + [ + flatpaks.homeManagerModules.nix-flatpak + ./home/${info.user}.nix + ] + ++ info.hmImports or []; + }; + } + ] + ++ info.imports or [] + ++ sharedModules; + }) + definitions; in { overlays = import ./util/overlay.nix {inherit inputs;}; - nixosConfigurations = { - "quiver" = nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = {inherit inputs outputs;}; - modules = - [ - ./system/quiver.nix - nixos-cosmic.nixosModules.default - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - extraSpecialArgs = {inherit inputs outputs;}; - users.bolt.imports = [ - flatpaks.homeManagerModules.nix-flatpak - ./home/bolt.nix - ]; - }; - } - ] - ++ sharedModules; + nixosConfigurations = createSystems { + quiver = { + user = "bolt"; }; - - "adrift" = nixpkgs.lib.nixosSystem { - inherit system; - specialArgs = {inherit inputs outputs;}; - modules = - [ - ./system/adrift.nix - nixos-cosmic.nixosModules.default - home-manager.nixosModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - extraSpecialArgs = {inherit inputs outputs;}; - users.plank.imports = [ - flatpaks.homeManagerModules.nix-flatpak - ./home/plank.nix - ]; - }; - } - ] - ++ sharedModules; + adrift = { + user = "plank"; }; }; }; diff --git a/home/bolt.nix b/home/bolt.nix index 6c77923..22949ab 100644 --- a/home/bolt.nix +++ b/home/bolt.nix @@ -4,7 +4,8 @@ ./util/local-webapp.nix ./util/containers.nix # ./programs/stable-diffusion.nix - ./programs/openwebui.nix + # ./programs/openwebui.nix + ./programs/sillytavern.nix ]; home = rec { diff --git a/home/modules/cosmic.nix b/home/modules/cosmic.nix index 04055c2..defe66a 100644 --- a/home/modules/cosmic.nix +++ b/home/modules/cosmic.nix @@ -69,11 +69,6 @@ in { config.cosmic = { enable = true; defaultKeybindings = false; - # otherSettings = { - # "com.system76.CosmicPanel.Dock" = { - # option.opacity = 0.8; - # }; - # }; keybindings = winManagementBindings ++ [ @@ -98,11 +93,11 @@ in { (binding "grave" ["Super" "Shift"] "MoveToPreviousOutput") (spawnBinding "equal" ["Super"] "keepassxc") (systemBinding "f" ["Super"] "WebBrowser") - (systemBinding "e" ["Super"] "HomeFolder") - # broken at the moment + # my mime handling is fucked + # (systemBinding "e" ["Super"] "HomeFolder") # (systemBinding "return" ["Super"] "Terminal") (spawnBinding "return" ["Super"] "kitty") - (systemBinding "s" ["Super" "Shift"] "Screenshot") + # (systemBinding "s" ["Super" "Shift"] "Screenshot") (systemBinding null ["Super"] "Launcher") (systemBinding "d" ["Super"] "AppLibrary") (systemBinding "XF86AudioRaiseVolume" [] "VolumeRaise") @@ -136,10 +131,10 @@ in { # (binding "grave" ["Super"] "PreviousOutput") # (binding "grave" ["Super" "Shift"] "MoveToPreviousOutput") # (spawnBinding "f" ["Super"] "firefox") - # (spawnBinding "e" ["Super"] "nautilus") + (spawnBinding "e" ["Super"] "nautilus") # (spawnBinding "equal" ["Super"] "keepassxc") # (spawnBinding "return" ["Super"] "kitty") - # (spawnBinding "s" ["Super" "Shift"] "cosmic-screenshot") + (spawnBinding "s" ["Super" "Shift"] "cosmic-screenshot") # (spawnBinding null ["Super"] "cosmic-launcher") # (spawnBinding "d" ["Super"] "cosmic-app-library") # (spawnBinding "XF86AudioRaiseVolume" [] "amixer sset Master 5%+") diff --git a/home/modules/documents.nix b/home/modules/documents.nix index b78f883..6da5298 100644 --- a/home/modules/documents.nix +++ b/home/modules/documents.nix @@ -1,11 +1,14 @@ -{...}: { +{pkgs, ...}: { imports = [ ../util/flatpak.nix ]; + home.packages = with pkgs; [ + libreoffice + ]; flatpaks = [ "md.obsidian.Obsidian" "com.logseq.Logseq" - "org.libreoffice.LibreOffice" + # "org.libreoffice.LibreOffice" "com.jgraph.drawio.desktop" ]; } diff --git a/home/programs/anything-llm.nix b/home/programs/anything-llm.nix new file mode 100644 index 0000000..62632d4 --- /dev/null +++ b/home/programs/anything-llm.nix @@ -0,0 +1,35 @@ +{ + lib, + pkgs, + ... +}: let + port = 3021; +in { + imports = [./ollama.nix]; + + localWebApps = { + anything-llm = { + name = "Anything LLM"; + genericName = "Chatbot"; + icon = ../icons/openwebui.png; + inherit port; + requires.containers = ["anything-llm" "ollama"]; + }; + }; + + services.podman = { + containers.anything-llm = let + str = builtins.toString; + in { + image = "mintplexlabs/anythingllm"; + ports = ["${str port}:3001"]; + autostart = false; + networks = ["ollama"]; + unitConfig = {Requires = ["podman-ollama.service"];}; + extraOptions = [ + "--health-cmd" + (lib.escapeShellArg "bash -c 'cat < /dev/null > /dev/tcp/localhost/3001'") + ]; + }; + }; +} diff --git a/home/programs/firefox.nix b/home/programs/firefox.nix index b98f949..431e89c 100644 --- a/home/programs/firefox.nix +++ b/home/programs/firefox.nix @@ -49,6 +49,7 @@ in { "keepassxc-browser@keepassxc.org" = officialAddon "keepassxc-browser"; "vimium-c@gdh1995.cn" = officialAddon "vimium-c"; "{b86e4813-687a-43e6-ab65-0bde4ab75758}" = officialAddon "localcdn-fork-of-decentraleyes"; + "jid1-5Fs7iTLscUaZBgwr@jetpack" = officialAddon "happy-bonobo-disable-webrtc"; }; Preferences = { diff --git a/home/programs/ollama.nix b/home/programs/ollama.nix index 0cab497..6daa2c6 100644 --- a/home/programs/ollama.nix +++ b/home/programs/ollama.nix @@ -5,9 +5,7 @@ }: { services.podman = { containers.ollama = { - # serviceName = "ollama"; image = "ollama/ollama:latest"; - # ports = ["11434:11434"]; devices = ["nvidia.com/gpu=all"]; autostart = false; networks = ["ollama"]; @@ -15,6 +13,7 @@ "--health-cmd" (lib.escapeShellArg "bash -c 'cat < /dev/null > /dev/tcp/localhost/11434'") ]; + # TODO make a volume lol }; networks.ollama = { diff --git a/mullvad/au-syd-wg-001.conf b/mullvad/au-syd-wg-001.conf new file mode 100644 index 0000000..bca625a --- /dev/null +++ b/mullvad/au-syd-wg-001.conf @@ -0,0 +1,10 @@ +[Interface] +# Device: Neat Sloth +PrivateKey = cDa2KkMYzCJRpvhq8Nt1ZnOieyS9xbrwfOn+iuPpwXw= +Address = 10.65.23.71/32,fc00:bbbb:bbbb:bb01::2:1746/128 +DNS = 10.64.0.1 + +[Peer] +PublicKey = 4JpfHBvthTFOhCK0f5HAbzLXAVcB97uAkuLx7E8kqW0= +AllowedIPs = 0.0.0.0/0,::0/0 +Endpoint = 146.70.200.2:51820 \ No newline at end of file diff --git a/mullvad/au-syd-wg-002.conf b/mullvad/au-syd-wg-002.conf new file mode 100644 index 0000000..ebfac9d --- /dev/null +++ b/mullvad/au-syd-wg-002.conf @@ -0,0 +1,10 @@ +[Interface] +# Device: Neat Sloth +PrivateKey = cDa2KkMYzCJRpvhq8Nt1ZnOieyS9xbrwfOn+iuPpwXw= +Address = 10.65.23.71/32,fc00:bbbb:bbbb:bb01::2:1746/128 +DNS = 10.64.0.1 + +[Peer] +PublicKey = lUeDAOy+iAhZDuz5+6zh0Co8wZcs3ahdu2jfqQoDW3E= +AllowedIPs = 0.0.0.0/0,::0/0 +Endpoint = 146.70.141.194:51820 \ No newline at end of file diff --git a/mullvad/au-syd-wg-003.conf b/mullvad/au-syd-wg-003.conf new file mode 100644 index 0000000..9ad01ff --- /dev/null +++ b/mullvad/au-syd-wg-003.conf @@ -0,0 +1,10 @@ +[Interface] +# Device: Neat Sloth +PrivateKey = cDa2KkMYzCJRpvhq8Nt1ZnOieyS9xbrwfOn+iuPpwXw= +Address = 10.65.23.71/32,fc00:bbbb:bbbb:bb01::2:1746/128 +DNS = 10.64.0.1 + +[Peer] +PublicKey = LXuRwa9JRTt2/UtldklKGlj/IVLORITqgET4II4DRkU= +AllowedIPs = 0.0.0.0/0,::0/0 +Endpoint = 146.70.200.194:51820 \ No newline at end of file diff --git a/mullvad/au-syd-wg-101.conf b/mullvad/au-syd-wg-101.conf new file mode 100644 index 0000000..0c7bbc0 --- /dev/null +++ b/mullvad/au-syd-wg-101.conf @@ -0,0 +1,10 @@ +[Interface] +# Device: Neat Sloth +PrivateKey = cDa2KkMYzCJRpvhq8Nt1ZnOieyS9xbrwfOn+iuPpwXw= +Address = 10.65.23.71/32,fc00:bbbb:bbbb:bb01::2:1746/128 +DNS = 10.64.0.1 + +[Peer] +PublicKey = NKP4jSvSDZg5HJ3JxpGYMxIYt7QzoxSFrU2F0m1ZxwA= +AllowedIPs = 0.0.0.0/0,::0/0 +Endpoint = 103.136.147.3:51820 \ No newline at end of file diff --git a/mullvad/au-syd-wg-102.conf b/mullvad/au-syd-wg-102.conf new file mode 100644 index 0000000..9589511 --- /dev/null +++ b/mullvad/au-syd-wg-102.conf @@ -0,0 +1,10 @@ +[Interface] +# Device: Neat Sloth +PrivateKey = cDa2KkMYzCJRpvhq8Nt1ZnOieyS9xbrwfOn+iuPpwXw= +Address = 10.65.23.71/32,fc00:bbbb:bbbb:bb01::2:1746/128 +DNS = 10.64.0.1 + +[Peer] +PublicKey = w825smx7YI9/SrwSYGdsuwD1Qt5UsS/CyaGTjwSYljU= +AllowedIPs = 0.0.0.0/0,::0/0 +Endpoint = 103.136.147.65:51820 \ No newline at end of file diff --git a/mullvad/au-syd-wg-103.conf b/mullvad/au-syd-wg-103.conf new file mode 100644 index 0000000..df5ffbc --- /dev/null +++ b/mullvad/au-syd-wg-103.conf @@ -0,0 +1,10 @@ +[Interface] +# Device: Neat Sloth +PrivateKey = cDa2KkMYzCJRpvhq8Nt1ZnOieyS9xbrwfOn+iuPpwXw= +Address = 10.65.23.71/32,fc00:bbbb:bbbb:bb01::2:1746/128 +DNS = 10.64.0.1 + +[Peer] +PublicKey = poOHsF6v91yURxDrNe/P/adyNUqsRGzhFIioyBYUPww= +AllowedIPs = 0.0.0.0/0,::0/0 +Endpoint = 103.136.147.129:51820 \ No newline at end of file diff --git a/mullvad/au-syd-wg-104.conf b/mullvad/au-syd-wg-104.conf new file mode 100644 index 0000000..f3de6dd --- /dev/null +++ b/mullvad/au-syd-wg-104.conf @@ -0,0 +1,10 @@ +[Interface] +# Device: Neat Sloth +PrivateKey = cDa2KkMYzCJRpvhq8Nt1ZnOieyS9xbrwfOn+iuPpwXw= +Address = 10.65.23.71/32,fc00:bbbb:bbbb:bb01::2:1746/128 +DNS = 10.64.0.1 + +[Peer] +PublicKey = 61Ovy3ObuHqllZK/P/5cOWZnY26SY2csmjzVK1q+fFs= +AllowedIPs = 0.0.0.0/0,::0/0 +Endpoint = 103.136.147.197:51820 \ No newline at end of file diff --git a/system/configuration.nix b/system/configuration.nix index a85951e..f4747c2 100644 --- a/system/configuration.nix +++ b/system/configuration.nix @@ -37,7 +37,7 @@ keep-derivations = true ''; optimise.automatic = true; - package = pkgs.lix; + # package = pkgs.lix; }; imports = [ @@ -103,5 +103,6 @@ # give cpuset to user systemd.services."user@".serviceConfig.Delegate = "memory pids cpu cpuset"; + systemd.user.extraConfig = "LogLevel=debug"; } diff --git a/system/modules/mullvad.nix b/system/modules/mullvad.nix new file mode 100644 index 0000000..6bd2efc --- /dev/null +++ b/system/modules/mullvad.nix @@ -0,0 +1,81 @@ +{ + lib, + pkgs, + ... +}: let + # gives some output like: + # Address = [ + # "10.10.10.10/32" + # ":::1746/128" + # ]; + # AllowedIPs = [ + # "0.0.0.0/0" + # "::0/0" + # ]; + # DNS = [ + # "10.64.0.1" + # ]; + # Endpoint = [ + # "1.2.3.4:51820" + # ]; + # PrivateKey = [ + # "xxx" + # ]; + # PublicKey = [ + # "xxx" + # ]; + inherit (lib) mapAttrs' mapAttrs mapAttrsToList listToAttrs splitString filter filterAttrs length head last; + inherit (builtins) readFile readDir; + # parseMullvad = file: { + # name = head (splitString "." file); + # value = listToAttrs (map (entry: { + # name = head entry; + # value = splitString "," (last entry); + # }) + # (filter (entry: (length entry) == 2) + # (map (line: splitString " = " line) + # (splitString "\n" (readFile ../../mullvad/${file}))))); + # }; + # definitions = + # map parseMullvad (getFiles ../../mullvad); + getFiles = path: + mapAttrsToList (n: v: n) + (filterAttrs (n: v: v == "regular") + (readDir path)); +in { + environment.systemPackages = [pkgs.wireguard-tools.out]; + networking.wg-quick.interfaces = listToAttrs (map (f: rec { + name = head (splitString "." f); + value = { + autostart = + if (name == "au-syd-wg-101") + then true + else false; + configFile = builtins.toString ../../mullvad/${f}; + }; + }) + (getFiles + ../../mullvad)); + # listToAttrs (map ({ + # name, + # value, + # }: { + # inherit name; + # value = { + # address = value.Address; + # peers = [ + # { + # allowedIPs = value.AllowedIPs; + # endpoint = head value.Endpoint; + # publicKey = head value.PublicKey; + # } + # ]; + # privateKey = head value.PrivateKey; + # autostart = + # if (name == "au-syd-wg-101") + # then true + # else false; + # }; + # }) + # definitions); +} diff --git a/system/modules/network.nix b/system/modules/network.nix index b8a49bc..1b3e19a 100644 --- a/system/modules/network.nix +++ b/system/modules/network.nix @@ -1,4 +1,7 @@ {...}: { + imports = [ + ./mullvad.nix + ]; networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. systemd.services.NetworkManager-wait-online.enable = true; # for some reason nm doesn't enable without this services.resolved = { diff --git a/util/overlay.nix b/util/overlay.nix index b5c72a5..ee77e3b 100644 --- a/util/overlay.nix +++ b/util/overlay.nix @@ -1,14 +1,4 @@ {...}: { additions = final: _prev: import ../.old/pkgs {pkgs = final;}; rice = import ./rice.nix; - # pkg-sets = final: prev: { - # unstable = import inputs.nixpkgs { - # system = final.system; - # config.allowUnfree = true; - # }; - # stable = import inputs.nixpkgs-stable { - # system = final.system; - # config.allowUnfree = true; - # }; - # }; }