From 19962bdc6ec2779bda7b3577c551fcc67cad5d3b Mon Sep 17 00:00:00 2001 From: Kat Huang Date: Wed, 26 Jul 2023 19:14:00 +0000 Subject: [PATCH] [NixOS] Add jay-lenovo-wsl and wsl support --- nixos/base.nix | 15 +- nixos/bootstrap/flake.lock | 347 +++++++----------------------- nixos/bootstrap/flake.nix | 3 +- nixos/flake.nix | 4 +- nixos/full.nix | 1 + nixos/kat.nix | 7 +- nixos/machines/jay-lenovo-wsl.nix | 10 + nixos/nix.nix | 17 ++ nixos/wsl.nix | 24 +++ 9 files changed, 147 insertions(+), 281 deletions(-) create mode 100644 nixos/machines/jay-lenovo-wsl.nix create mode 100644 nixos/nix.nix create mode 100644 nixos/wsl.nix diff --git a/nixos/base.nix b/nixos/base.nix index a857e8f2..9e50fa17 100644 --- a/nixos/base.nix +++ b/nixos/base.nix @@ -1,25 +1,12 @@ { config, pkgs, options, inputs, ... }: { imports = [ + ./nix.nix ./users.nix ./essential.nix ./environment.nix ]; - nix = { - extraOptions = '' - experimental-features = nix-command flakes - ''; - registry.nixpkgs.flake = inputs.nixpkgs; - }; - - nixpkgs.overlays = with inputs; [ - nix.overlays.default - (import ./overlay.nix) - ]; - - # Allow all the things - nixpkgs.config.allowUnfree = true; nixpkgs.config.permittedInsecurePackages = [ "openssl-1.0.2u" ]; diff --git a/nixos/bootstrap/flake.lock b/nixos/bootstrap/flake.lock index 555a1bea..7f37a246 100644 --- a/nixos/bootstrap/flake.lock +++ b/nixos/bootstrap/flake.lock @@ -16,6 +16,22 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": [ @@ -23,11 +39,29 @@ ] }, "locked": { - "lastModified": 1687709756, - "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "owner": "numtide", "repo": "flake-utils", - "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "type": "github" }, "original": { @@ -56,61 +90,6 @@ "type": "github" } }, - "gtk-sni-tray": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "git-ignore-nix": [ - "git-ignore-nix" - ], - "nixpkgs": [ - "nixpkgs" - ], - "status-notifier-item": [ - "status-notifier-item" - ] - }, - "locked": { - "lastModified": 1663379298, - "narHash": "sha256-m18+G7V1N+g/pPeKJG9hkblGA5c8QTnUYnsU5t14sOw=", - "owner": "taffybar", - "repo": "gtk-sni-tray", - "rev": "1927d86308d34b5d21a709cf8ff5332ec5d37de4", - "type": "github" - }, - "original": { - "owner": "taffybar", - "repo": "gtk-sni-tray", - "type": "github" - } - }, - "gtk-strut": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "git-ignore-nix": [ - "git-ignore-nix" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1663377859, - "narHash": "sha256-UrBd+R3NaJIDC2lt5gMafS3KBeLs83emm2YorX2cFCo=", - "owner": "taffybar", - "repo": "gtk-strut", - "rev": "d946eb230cdccf5afc063642b3215723e555990b", - "type": "github" - }, - "original": { - "owner": "taffybar", - "repo": "gtk-strut", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -118,11 +97,11 @@ ] }, "locked": { - "lastModified": 1687969886, - "narHash": "sha256-tC2qFLmuM0PFaw0tMHVcFmzsG/351q09qa1EpuL2n1U=", + "lastModified": 1690303752, + "narHash": "sha256-2YiwFHQERGoaORNORmsdmVlPD8CVVwlwbV2+f77sFhg=", "owner": "nix-community", "repo": "home-manager", - "rev": "a7002d6bfca54742d5fc9b485a1879953b4585b9", + "rev": "ba2c0737cc848db03470828fdb5e86df75ed42a8", "type": "github" }, "original": { @@ -131,32 +110,6 @@ "type": "github" } }, - "imalison-taffybar": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "nixpkgs": [ - "nixpkgs" - ], - "taffybar": [ - "taffybar" - ], - "xmonad": [ - "xmonad" - ] - }, - "locked": { - "lastModified": 1, - "narHash": "sha256-FDbBPRbfABuZ92x5azeEOIayP1AVnmF1KhFEi/rTTLo=", - "path": "../../dotfiles/config/taffybar", - "type": "path" - }, - "original": { - "path": "../../dotfiles/config/taffybar", - "type": "path" - } - }, "lowdown-src": { "flake": false, "locked": { @@ -198,11 +151,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1686838567, - "narHash": "sha256-aqKCUD126dRlVSKV6vWuDCitfjFrZlkwNuvj5LtjRRU=", + "lastModified": 1690200740, + "narHash": "sha256-aRkEXGmCbAGcvDcdh/HB3YN+EvoPoxmJMOaqRZmf6vM=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "429f232fe1dc398c5afea19a51aad6931ee0fb89", + "rev": "ba9650b14e83b365fb9e731f7d7c803f22d2aecf", "type": "github" }, "original": { @@ -211,18 +164,38 @@ "type": "github" } }, + "nixos-wsl": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1690187332, + "narHash": "sha256-8iyH0LXszole3kUjPfg4S8uprJ0RGDQbZLyBvKFiQ3s=", + "owner": "nix-community", + "repo": "NixOS-WSL", + "rev": "01112baf546b5577038e2a422a5215eedd9bc84b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NixOS-WSL", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1687898314, - "narHash": "sha256-B4BHon3uMXQw8ZdbwxRK1BmxVOGBV4viipKpGaIlGwk=", + "lastModified": 1689605451, + "narHash": "sha256-u2qp2k9V1smCfk6rdUcgMKvBj3G9jVvaPHyeXinjN9E=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e18dc963075ed115afb3e312b64643bf8fd4b474", + "rev": "53657afe29748b3e462f1f892287b7e254c26d77", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixos-23.05", "repo": "nixpkgs", "type": "github" } @@ -243,91 +216,32 @@ "type": "github" } }, - "nixpkgs-regression_2": { + "nixpkgs_2": { "locked": { - "lastModified": 1688001024, - "narHash": "sha256-Zf88j+DUj6rDgveWfdEyUo4fL1KZTowzPAN6gpeqzKg=", + "lastModified": 1690179384, + "narHash": "sha256-+arbgqFTAtoeKtepW9wCnA0njCOyoiDFyl0Q0SBSOtE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2c8591ad6a6f9d679817a94f847c59b0d1e3289e", + "rev": "b12803b6d90e2e583429bb79b859ca53c348b39a", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, - "notifications-tray-icon": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "git-ignore-nix": [ - "git-ignore-nix" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1627789093, - "narHash": "sha256-rnQ7vDF9g2xqRpw62lkCyxBiq6cXhWgfoF7lx1WoNMI=", - "owner": "IvanMalison", - "repo": "notifications-tray-icon", - "rev": "2fd47641d0cb046c78de9b4577cb30bc49e607ea", - "type": "github" - }, - "original": { - "owner": "IvanMalison", - "repo": "notifications-tray-icon", - "type": "github" - } - }, "root": { "inputs": { "flake-utils": "flake-utils", "git-ignore-nix": "git-ignore-nix", - "gtk-sni-tray": "gtk-sni-tray", - "gtk-strut": "gtk-strut", "home-manager": "home-manager", - "imalison-taffybar": "imalison-taffybar", "nix": "nix", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs", - "nixpkgs-regression": "nixpkgs-regression_2", - "notifications-tray-icon": "notifications-tray-icon", - "status-notifier-item": "status-notifier-item", - "systems": "systems", - "taffybar": "taffybar", - "xmonad": "xmonad", - "xmonad-contrib": "xmonad-contrib" - } - }, - "status-notifier-item": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "git-ignore-nix": [ - "git-ignore-nix" - ], - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1641783528, - "narHash": "sha256-wJymJfYPFj4/r1e4kT/wt9FEsyCXo5JkkcOoozpuhag=", - "owner": "taffybar", - "repo": "status-notifier-item", - "rev": "f4f9c66ab57fc42eeed0de8cfac9f5f9d30d9dc7", - "type": "github" - }, - "original": { - "owner": "taffybar", - "repo": "status-notifier-item", - "type": "github" + "nixos-wsl": "nixos-wsl", + "nixpkgs": "nixpkgs_2", + "systems": "systems_2" } }, "systems": { @@ -345,113 +259,18 @@ "type": "github" } }, - "taffybar": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "git-ignore-nix": [ - "git-ignore-nix" - ], - "gtk-sni-tray": [ - "gtk-sni-tray" - ], - "gtk-strut": [ - "gtk-strut" - ], - "nixpkgs": [ - "nixpkgs" - ], - "xmonad": [ - "xmonad" - ] - }, + "systems_2": { "locked": { - "lastModified": 1685567526, - "narHash": "sha256-JvoCkRmKzdJwoHL+m29W845eJmp4bRdlYiqUabHvzhY=", - "owner": "taffybar", - "repo": "taffybar", - "rev": "741995d09da1264da669d69c6c26fe4575c5d4ba", + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { - "owner": "taffybar", - "ref": "master", - "repo": "taffybar", - "type": "github" - } - }, - "unstable": { - "locked": { - "lastModified": 1687898314, - "narHash": "sha256-B4BHon3uMXQw8ZdbwxRK1BmxVOGBV4viipKpGaIlGwk=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "e18dc963075ed115afb3e312b64643bf8fd4b474", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "xmonad": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "git-ignore-nix": [ - "git-ignore-nix" - ], - "nixpkgs": [ - "nixpkgs" - ], - "unstable": "unstable" - }, - "locked": { - "lastModified": 1663511234, - "narHash": "sha256-gyIoxSygmW/d29P45kq/V1LlLlJ8jkT2D7O0OtdPcSc=", - "owner": "IvanMalison", - "repo": "xmonad", - "rev": "a2259bb3091429f4293d371e13fd5a2ee8da30db", - "type": "github" - }, - "original": { - "owner": "IvanMalison", - "ref": "master", - "repo": "xmonad", - "type": "github" - } - }, - "xmonad-contrib": { - "inputs": { - "flake-utils": [ - "flake-utils" - ], - "git-ignore-nix": [ - "git-ignore-nix" - ], - "nixpkgs": [ - "nixpkgs" - ], - "xmonad": [ - "xmonad" - ] - }, - "locked": { - "lastModified": 1686731483, - "narHash": "sha256-gARNKrY2Eud5BlW8CyJVJ29owfNLZRF3Ov/QMGjCItc=", - "owner": "IvanMalison", - "repo": "xmonad-contrib", - "rev": "ac9bc49022ca7d1076d00ab87e7ecc45216117b8", - "type": "github" - }, - "original": { - "owner": "IvanMalison", - "ref": "withMyChanges", - "repo": "xmonad-contrib", + "owner": "nix-systems", + "repo": "default", "type": "github" } } diff --git a/nixos/bootstrap/flake.nix b/nixos/bootstrap/flake.nix index ebc2cb75..e09d304e 100644 --- a/nixos/bootstrap/flake.nix +++ b/nixos/bootstrap/flake.nix @@ -25,6 +25,7 @@ url = github:hercules-ci/gitignore.nix; inputs.nixpkgs.follows = "nixpkgs"; }; + nixos-wsl = { url = github:nix-community/NixOS-WSL; }; }; outputs = inputs@{ @@ -50,7 +51,7 @@ mkConfigurationParams = filename: { name = machineNameFromFilename filename; value = { - modules = [ (machinesPath + ("/" + filename)) ../base.nix ]; + modules = [ (machinesPath + ("/" + filename)) ]; }; }; defaultConfigurationParams = diff --git a/nixos/flake.nix b/nixos/flake.nix index 10548d3c..5d8c1fb7 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -107,6 +107,8 @@ nixpkgs-regression = { url = github:NixOS/nixpkgs; }; nixified-ai = { url = github:nixified-ai/flake; }; + + nixos-wsl = { url = github:nix-community/NixOS-WSL; }; }; outputs = inputs@{ @@ -138,7 +140,7 @@ mkConfigurationParams = filename: { name = machineNameFromFilename filename; value = { - modules = [ (machinesFilepath + ("/" + filename)) ./base.nix ]; + modules = [ (machinesFilepath + ("/" + filename)) ]; }; }; defaultConfigurationParams = diff --git a/nixos/full.nix b/nixos/full.nix index 42bdc9b5..ba9a0d2f 100644 --- a/nixos/full.nix +++ b/nixos/full.nix @@ -3,6 +3,7 @@ imports = [ ./android.nix ./arm-incompatible.nix + ./base.nix ./games.nix ./desktop.nix ./xmonad.nix diff --git a/nixos/kat.nix b/nixos/kat.nix index cbc604d1..050b819c 100644 --- a/nixos/kat.nix +++ b/nixos/kat.nix @@ -1,5 +1,8 @@ -{ pkgs, ... }: +{ pkgs, inputs, ... }: { + imports = [ + inputs.home-manager.nixosModule + ]; environment.systemPackages = with pkgs; [ bitwarden obsidian @@ -8,6 +11,8 @@ ffmpeg ]; + networking.hostName = "jay-lenovo-wsl"; + home-manager.users.kat = { pkgs, config, ... }: { services.gpg-agent = { enable = true; diff --git a/nixos/machines/jay-lenovo-wsl.nix b/nixos/machines/jay-lenovo-wsl.nix new file mode 100644 index 00000000..59975cb6 --- /dev/null +++ b/nixos/machines/jay-lenovo-wsl.nix @@ -0,0 +1,10 @@ +{ lib, pkgs, config, inputs, ... }: +{ + imports = [ + ../wsl.nix + ../kat.nix + ]; + + wsl.defaultUser = "kat"; + system.stateVersion = "22.05"; +} diff --git a/nixos/nix.nix b/nixos/nix.nix new file mode 100644 index 00000000..06608a4c --- /dev/null +++ b/nixos/nix.nix @@ -0,0 +1,17 @@ +{ inputs, ... }: +{ + nix = { + extraOptions = '' + experimental-features = nix-command flakes + ''; + registry.nixpkgs.flake = inputs.nixpkgs; + }; + + nixpkgs.overlays = with inputs; [ + # nix.overlays.default + (import ./overlay.nix) + ]; + + # Allow all the things + nixpkgs.config.allowUnfree = true; +} diff --git a/nixos/wsl.nix b/nixos/wsl.nix new file mode 100644 index 00000000..19274985 --- /dev/null +++ b/nixos/wsl.nix @@ -0,0 +1,24 @@ +{ inputs, ... }: +{ + imports = [ + inputs.nixos-wsl.nixosModules.wsl + ./nix.nix + ./users.nix + ./essential.nix + ./environment.nix + ]; + + programs.gnupg.agent = { enable = true; enableSSHSupport = true; }; + + wsl = { + enable = true; + automountPath = "/mnt"; + startMenuLaunchers = true; + + # Enable native Docker support + # docker-native.enable = true; + + # Enable integration with Docker Desktop (needs to be installed) + # docker-desktop.enable = true; + }; +}