diff --git a/flake.lock b/flake.lock index 0a9f277..8458e7d 100644 --- a/flake.lock +++ b/flake.lock @@ -42,6 +42,40 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -100,6 +134,28 @@ "type": "github" } }, + "nixos-wsl": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1698222534, + "narHash": "sha256-iF9C7C7eT8LVVWx5IOZ/8KKJT8AIw9A5aBA6vqS18l8=", + "owner": "nix-community", + "repo": "NixOS-WSL", + "rev": "a058cff4b09b3a398d8caa379b4dc96cfedd98c9", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NixOS-WSL", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1677676435, @@ -152,9 +208,25 @@ "agenix": "agenix", "home-manager": "home-manager_2", "nixos-hardware": "nixos-hardware", + "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs_2", "nixpkgs-unstable": "nixpkgs-unstable" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index f5b8125..4557b6f 100644 --- a/flake.nix +++ b/flake.nix @@ -10,8 +10,12 @@ url = "github:nix-community/home-manager/release-23.05"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixos-wsl = { + url = "github:nix-community/NixOS-WSL"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, nixos-hardware, nixpkgs-unstable, agenix, home-manager }@inputs: + outputs = { self, nixpkgs, nixos-hardware, nixos-wsl, nixpkgs-unstable, agenix, home-manager }@inputs: let system = "x86_64-linux"; overlay-unstable = final: prev: { @@ -65,5 +69,14 @@ agenix.nixosModules.default ]; }; + nixosConfigurations."wsl" = nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = { inherit inputs; }; + modules = [ + ./systems/wsl/configuration.nix + nixos-wsl.nixosModules.default + home-manager.nixosModules.home-manager + ]; + }; }; } diff --git a/systems/wsl/configuration.nix b/systems/wsl/configuration.nix new file mode 100644 index 0000000..b3bb892 --- /dev/null +++ b/systems/wsl/configuration.nix @@ -0,0 +1,55 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +# NixOS-WSL specific options are documented on the NixOS-WSL repository: +# https://github.com/nix-community/NixOS-WSL + +{ config, lib, pkgs, ... } : #nixos-wsl, ... }: + +{ + imports = [ + # include NixOS-WSL modules +# + ]; + + wsl.enable = true; + wsl.defaultUser = "nixos"; + nix.optimise.automatic = true; + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 30d"; + }; + nix.settings.trusted-substituters = [ "https://ai.cachix.org" ]; + nix.settings.trusted-public-keys = [ "ai.cachix.org-1:N9dzRK+alWwoKXQlnn0H6aUx0lU/mspIoz8hMvGvbbc=" ]; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + environment.systemPackages = with pkgs; [ + neofetch + openssh + ]; + + wsl.wslConf = { + interop = { enabled = false; appendWindowsPath = false; }; + }; + + networking.hostName = "wsl"; + + home-manager.users.nixos = { pkgs, ... }: { + programs.bash.enable = true; + programs.git = { + enable = true; + }; + # The state version is required and should stay at the version you + # originally installed. + home.stateVersion = "23.05"; + }; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It's perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.05"; # Did you read the comment? +}