-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
76 lines (61 loc) · 2.29 KB
/
flake.nix
File metadata and controls
76 lines (61 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File: flake.nix
# -----------------
# This is the entry point. It defines the project's dependencies
# (Nixpkgs, NixOS-WSL, Home Manager) and its outputs (the
# WSL system configuration and the tarball).
{
description = "NixOS-WSL configuration for [Your Team Name]";
inputs = {
# Nixpkgs (for packages)
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# NixOS-WSL
nixos-wsl.url = "github:nix-community/NixOS-WSL";
# Home Manager (for user-level configs)
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# Flake utilities
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, nixos-wsl, home-manager, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
# Build a NixOS system configured with our modules
nixosSystem = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit home-manager; }; # Pass home-manager to the config
modules = [
# Import the NixOS-WSL module
nixos-wsl.nixosModules.wsl
# Import our custom system configuration
./configuration.nix
{ nix.settings.sandbox = false; }
];
};
in
{
# The main configuration to be built
nixosConfigurations.wsl-dev-env = nixosSystem;
# This packages the configuration as a WSL tarball
# Build it with: sudo nix run .#wsl-tarball
packages.wsl-tarball = nixpkgs.legacyPackages.${system}.writeShellScriptBin "wsl-tarball-builder" ''
set -e
# Create output directory
mkdir -p output
# Run the tarball builder
${nixosSystem.config.system.build.tarballBuilder}/bin/nixos-wsl-tarball-builder
# Move the generated tarball to output/nixos.wsl
if [ -f nixos.wsl ]; then
mv nixos.wsl output/nixos.wsl
echo "WSL tarball created at: output/nixos.wsl"
else
echo "Error: nixos.wsl not found after build"
exit 1
fi
'';
# Make it the default package
# Build it with: nix build
packages.default = self.packages.${system}.wsl-tarball;
});
}