From 6e7f5ae446c72d77beaed2c1f17d4ef7c0d76823 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Wed, 28 Dec 2022 15:39:44 -0600 Subject: [PATCH] Add WSL2 target for builds --- flake.lock | 56 ++++++++++++++++++++++++++++++++++++++++++- flake.nix | 11 ++++++++- hosts/wsl/default.nix | 10 ++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 hosts/wsl/default.nix diff --git a/flake.lock b/flake.lock index 20adcb3..9b4372b 100644 --- a/flake.lock +++ b/flake.lock @@ -57,6 +57,37 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -149,7 +180,8 @@ "home-manager": "home-manager", "nixunstable": "nixunstable", "nurpkgs": "nurpkgs", - "stable": "stable" + "stable": "stable", + "wsl": "wsl" } }, "stable": { @@ -167,6 +199,28 @@ "repo": "nixpkgs", "type": "github" } + }, + "wsl": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixunstable" + ] + }, + "locked": { + "lastModified": 1671740841, + "narHash": "sha256-y9xl0aYI9uOJpNabIVja7aksDgV5nMgH8MsWaEOW2bM=", + "owner": "nix-community", + "repo": "NixOS-WSL", + "rev": "3ec8fafb7b5d1463cb166233cf18bf495dd8e944", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NixOS-WSL", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 9423ee0..4f43dfc 100644 --- a/flake.nix +++ b/flake.nix @@ -16,11 +16,15 @@ url = "github:lnl7/nix-darwin/master"; inputs.nixpkgs.follows = "nixunstable"; }; + wsl = { + url = "github:nix-community/NixOS-WSL"; + inputs.nixpkgs.follows = "nixunstable"; + }; nurpkgs.url = "github:nix-community/NUR"; ffmac.url = "github:bandithedoge/nixpkgs-firefox-darwin"; }; - outputs = {stable, nixunstable, agenix, home-manager, nurpkgs, self, ...}@inputs: + outputs = {stable, nixunstable, agenix, home-manager, nurpkgs, self, wsl, ...}@inputs: let local_overlay = import ./overlays; overlays = [ @@ -42,6 +46,7 @@ modules = [ { nixpkgs.overlays = overlays; } agenix.nixosModule + wsl.nixosModules.wsl ./modules-all ./modules-linux ./hosts/${name} @@ -76,6 +81,10 @@ "linode" = machine { name = "linode"; }; "lappy" = machine { name = "lappy"; }; "iso" = machine { name = "iso"; }; + # nix build '.#nixosConfigurations.wsl.config.system.build.installer' + "wsl" = machine { name = "wsl"; }; + # nix build '.#nixosConfigurations.wsl-aarch.config.system.build.installer' + "wsl-aarch" = machine { name = "wsl"; system = "aarch64-linux"; }; }; darwinConfigurations = diff --git a/hosts/wsl/default.nix b/hosts/wsl/default.nix new file mode 100644 index 0000000..3eeaf4e --- /dev/null +++ b/hosts/wsl/default.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: + +{ + wsl = { + enable = true; + wslConf.automount.root = "/mnt"; + defaultUser = "greg"; + startMenuLaunchers = true; + }; +}