Skip to content

Commit

Permalink
feat(nix): initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LGUG2Z committed Sep 28, 2023
0 parents commit 63f8b70
Show file tree
Hide file tree
Showing 9 changed files with 949 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*key
.idea
result
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Getting Started

* Get the [latest NixOS-WSL installer](https://github.com/nix-community/NixOS-WSL/actions/runs/6159516082)
* Install it (tweak the command to your desired paths): `wsl --import NixOS .\NixOS\ .\nixos-wsl-installer.tar.gz --version 2`
* Enter the distro with `wsl -d NixOs`
* Get a copy of this repo
```bash
cd ~
nix-shell -p busybox
curl -L https://github.com/LGUG2Z/nixos-wsl-starter/archive/refs/heads/master.zip | unzip -
mv nixos-wsl-starter-master configuration
```
* Change the username to your desired username in `flake.nix`
* Apply the configuration with `sudo nixos-rebuild switch --impure --flake ~/configuration`
* Disconnect from your current WSL shell and then reconnect again with `wsl -d NixOS`
* `cd` and then `pwd` should now show `/home/<YOUR_USERNAME>`
* Do this bit again because the temporary initial home directory was blown away when we applied our configuration
```bash
cd ~
nix-shell -p busybox
curl -L https://github.com/LGUG2Z/nixos-wsl-starter/archive/refs/heads/master.zip | unzip -
mv nixos-wsl-starter-master configuration
```
* Install LunarVim: `LV_BRANCH='release-1.3/neovim-0.9' bash <(curl -s https://raw.githubusercontent.com/LunarVim/LunarVim/release-1.3/neovim-0.9/utils/installer/install.sh)` (select "no" for all dependency prompts)
* Change the username to your desired username in `flake.nix` one last time
* Go through all the `FIXME:` notices in `~/configuration` and make changes wherever you want
* Apply any further changes with `sudo nixos-rebuild switch --impure --flake ~/configuration`
103 changes: 103 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
description = "NixOS configuration";

inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
inputs.nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";

inputs.home-manager.url = "github:nix-community/home-manager/release-23.05";
inputs.home-manager.inputs.nixpkgs.follows = "nixpkgs";

inputs.nur.url = "github:nix-community/NUR";

inputs.nix-index-database.url = "github:Mic92/nix-index-database";
inputs.nix-index-database.inputs.nixpkgs.follows = "nixpkgs";

outputs = inputs:
with inputs; let
secrets = builtins.fromJSON (builtins.readFile "${self}/secrets.json");

nixpkgsWithOverlays = with inputs; rec {
config = {
allowUnfree = true;
permittedInsecurePackages = [
# FIXME:: add any insecure packages you absolutely need here
"python-2.7.18.6" # needed for core-utils
];
};
overlays = [
nur.overlay
(_final: prev: {
# this allows us to reference pkgs.unstable
unstable = import nixpkgs-unstable {
inherit (prev) system;
inherit config;
};
})
];
};

configurationDefaults = args: {
nixpkgs = nixpkgsWithOverlays;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "hm-backup";
home-manager.extraSpecialArgs = args;
};

argDefaults = {
inherit secrets inputs self nix-index-database;
channels = {
inherit nixpkgs nixpkgs-unstable;
};
};

mkNixosConfiguration = {
system ? "x86_64-linux",
hostname,
username,
args ? {},
modules,
}: let
specialArgs = argDefaults // {inherit hostname username;} // args;
in
nixpkgs.lib.nixosSystem {
inherit system specialArgs;
modules =
[
(configurationDefaults specialArgs)
home-manager.nixosModules.home-manager
]
++ modules;
};
in {
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra;

nixosConfigurations.nixos = mkNixosConfiguration {
hostname = "nixos";
username = "example-user"; # FIXME: replace with your own username!
modules = [./wsl.nix];
};
};
}
Loading

0 comments on commit 63f8b70

Please sign in to comment.