Initial commit

This commit is contained in:
Whovian NTSN 2024-05-07 15:37:50 -04:00
parent ac8e9eb1bd
commit a79d51fa50
10 changed files with 626 additions and 2 deletions

View file

@ -1,3 +1,10 @@
# nixos_config # Whovian's system flake
I needed to put my config into a `git` repo, so I made my first system config flake (and added my `home-manager` setup too.) and committed it.
If you have suggestions on "fixing" or "cleaning up" my configurations, please add it to the [Discussions](about:blank) so I can take a look at it later!
### Future reference:
[[github:eclairevoyant/flake-migration - /nixos.md]How to switch to flakes from path-based nix](https://github.com/eclairevoyant/flake-migration/blob/main/nixos.md)
[[NixOS-WSL GitHub/Site] How to configure NixOS-WSL with flakes?](https://nix-community.github.io/NixOS-WSL/howto.html)
[[Xe Iaso] Nix Flakes on WSL](https://xeiaso.net/blog/nix-flakes-4-wsl-2022-05-01/)
[[Home-Manager GitHub/Site] Setting up `home-manager` as a NixOS module.](https://nix-community.github.io/home-manager/index.xhtml#sec-flakes-nixos-module)
Meant as a temporary repo for configuration maintenance, so just testing atm

221
flake.lock Normal file
View file

@ -0,0 +1,221 @@
{
"nodes": {
"agenix": {
"inputs": {
"darwin": "darwin",
"home-manager": "home-manager",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems"
},
"locked": {
"lastModified": 1714136352,
"narHash": "sha256-BtWQ2Th/jamO1SlD+2ASSW5Jaf7JhA/JLpQHk0Goqpg=",
"owner": "ryantm",
"repo": "agenix",
"rev": "24a7ea390564ccd5b39b7884f597cfc8d7f6f44e",
"type": "github"
},
"original": {
"owner": "ryantm",
"repo": "agenix",
"type": "github"
}
},
"darwin": {
"inputs": {
"nixpkgs": [
"agenix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1700795494,
"narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"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_2"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"agenix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1703113217,
"narHash": "sha256-7ulcXOk63TIT2lVDSExj7XzFx09LpdSAPtvgtM7yQPE=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "3bfaacf46133c037bb356193bd2f1765d9dc82c1",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"home-manager_2": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1714981474,
"narHash": "sha256-b3/U21CJjCjJKmA9WqUbZGZgCvospO3ArOUTgJugkOY=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "6ebe7be2e67be7b9b54d61ce5704f6fb466c536f",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"my_packages": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1715061149,
"narHash": "sha256-ZM13/Z/7W9POKVIoMIJzRRzKY8v9oMD1nhLdXej0pFY=",
"path": "/home/whovian/.flakes",
"type": "path"
},
"original": {
"path": "/home/whovian/.flakes",
"type": "path"
}
},
"nixos-wsl": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1715017675,
"narHash": "sha256-4bMsnv8KLzz8HWvYzeIjKqRF7IRCLSjo3EC862+L2Dk=",
"owner": "nix-community",
"repo": "NixOS-WSL",
"rev": "1cb8f3c13dee0d40437a9b4b1cf943c06c0cddc4",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "main",
"repo": "NixOS-WSL",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1714906307,
"narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "25865a40d14b3f9cf19f19b924e2ab4069b09588",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"agenix": "agenix",
"home-manager": "home-manager_2",
"my_packages": "my_packages",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"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",
"version": 7
}

66
flake.nix Normal file
View file

@ -0,0 +1,66 @@
{
description = "Whovian9369's WSL NixOS Config";
inputs = {
### Basically required
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-unstable";
};
nixos-wsl = {
url = "github:nix-community/NixOS-WSL/main";
inputs.nixpkgs.follows = "nixpkgs";
};
### My extra inputs
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
# optional, not necessary for the module
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
my_packages = {
url = "/home/whovian/.flakes";
inputs.nixpkgs.follows = "nixpkgs";
};
}; # inputs
outputs = { self, nixpkgs, nixos-wsl, agenix, home-manager, my_packages, ... }:
{
nixosConfigurations = {
nixos-wsl = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./system/configuration.nix
nixos-wsl.nixosModules.wsl
home-manager.nixosModules.home-manager
{
home-manager = {
# users.whovian = import ./home/home.nix;
sharedModules = [
./home/home.nix
agenix.homeManagerModules.default
];
users.whovian.home.packages = [
agenix.packages.x86_64-linux.default
];
# Optionally, use home-manager.extraSpecialArgs to pass arguments to home.nix
extraSpecialArgs = {
system = "x86_64-linux";
inherit my_packages;
my_pkgs = my_packages.packages.x86_64-linux;
};
};
}
];
};
};
};
}

206
home/home.nix Normal file
View file

@ -0,0 +1,206 @@
{
config,
pkgs,
my_pkgs,
...
}:
{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "whovian";
home.homeDirectory = "/home/whovian";
/*
This value determines the Home Manager release that your configuration is
compatible with. This helps avoid breakage when a new Home Manager release
introduces backwards incompatible changes.
You should not change this value, even if you update Home Manager. If you do
want to update the value, then make sure to first check the Home Manager
release notes.
*/
home.stateVersion = "23.05"; # Please read the comment before changing.
# The home.packages option allows you to install Nix packages into your
# environment.
nixpkgs = {
config = {
allowUnfree = true;
};
};
home.packages = [
pkgs._7zz
pkgs.bat
pkgs.binwalk
pkgs.cdecrypt
pkgs.colorized-logs
pkgs.croc
pkgs.dhex
pkgs.file
pkgs.gdrive3
pkgs.git
pkgs.hactool
pkgs.instaloader
pkgs.internetarchive
pkgs.lynx
pkgs.megatools
pkgs.ncdu
pkgs.nixfmt-classic
pkgs.progress
pkgs.pyrosimple # `lstor` etc, seems to be a `pyrocore` fork?
pkgs.python3
pkgs.quickbms
pkgs.rclone
pkgs.screen
pkgs.sshfs
pkgs.unrar-wrapper
pkgs.wget
pkgs.xxd
pkgs.yq
# my_pkgs.irdkit
my_pkgs.ird_tools
my_pkgs.rom-properties
];
/*
Disabled
pkgs.binutils
# Instead just do `nix shell nixpkgs#binutils -c strings -- INPUT.ext > INPUT.ext.strings
pkgs.jq
pkgs.mpv
pkgs.ripgrep
pkgs.terminator
pkgs.yt-dlp
pkgs.p7zip
# Replaced in favour of nixpkgs#_7zz
Disabled
*/
/*
# It is sometimes useful to fine-tune packages, for example, by applying
# overrides. You can do that directly here, just don't forget the
# parentheses. Maybe you want to install Nerd Fonts with a limited number of
# fonts?
(pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
*/
age = {
identityPaths = [
/home/whovian/.ssh/id_ed25519.nix
];
secrets = {
cursed = {
file = ./secrets/curse.age;
};
openai = {
file = ./secrets/openai_key.age;
};
};
};
programs = {
bat = {
enable = true;
};
direnv = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
nix-direnv.enable = true;
};
git = {
enable = true;
userName = "Whovian9369";
userEmail = "Whovian9369@gmail.com";
extraConfig = {
init = {
defaultBranch = "main";
};
};
};
jq = {
enable = true;
};
ripgrep = {
enable = true;
};
zsh = {
enable = true;
# Honestly unsure if I should be using `programs.zsh.envExtra` or
# `programs.zsh.localVariables` here.
localVariables = {
DISABLE_MAGIC_FUNCTIONS = true;
};
# enableAutosuggestions = true;
# enableCompletion = true;
oh-my-zsh = {
enable = true;
plugins = [
"git"
"sudo"
];
theme = "bira";
};
};
};
home.file = {
/*
# Building this configuration will create a copy of 'dotfiles/screenrc' in
# the Nix store. Activating the configuration will then make '~/.screenrc' a
# symlink to the Nix store copy.
".screenrc".source = dotfiles/screenrc;
# You can also set the file content immediately.
".gradle/gradle.properties".text = ''
org.gradle.console=verbose
org.gradle.daemon.idletimeout=3600000
'';
*/
".zshrc".text = ''
eval "$(direnv hook zsh)"
download_nixpkgs_cache_index () {
filename="index-$(uname -m | sed 's/^arm64$/aarch64/')-$(uname | tr A-Z a-z)"
mkdir -p ~/.cache/nix-index && cd ~/.cache/nix-index
# -N will only download a new version if there is an update.
wget -q -N https://github.com/Mic92/nix-index-database/releases/latest/download/$filename
ln -f $filename files
}
'';
".lftp/rc".text = ''
alias s32 "mirror -c --use-pget-n=32"
alias p32 "pget -n 32 -c"
alias p16 "pget -n 16 -c"
alias s16 "mirror -c --use-pget-n=16"
alias p8 "pget -n 8 -c"
alias ssl "set ssl:verify-certificate false"
'';
};
home.sessionVariables = {
EDITOR = "nano";
DOTNET_CLI_TELEMETRY_OPTOUT = "1";
OPENAI_API_KEY = "\$(cat ${config.age.secrets."openai".path})";
CURSEFORGE_API_KEY = "\$(cat ${config.age.secrets."cursed".path})";
};
home.shellAliases = {
"adb" = "adb.exe";
"caja" = "explorer.exe";
"hactoolnet" = "hactoolnet.exe";
"mpv" = "mpv.com";
"tailscale" = "tailscale.exe";
"yt-dlp" = "yt-dlp.exe";
"7zexe" = "/mnt/c/Program\\ Files/7-Zip/7z.exe";
"7z" = "7zz";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

7
home/secrets.nix Normal file
View file

@ -0,0 +1,7 @@
let
whovian = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKUpUbEtBSySMW82Wm4xOtlGKxnPf8bqKxVMRJH3Sycx";
in
{
"secrets/openai_key.age".publicKeys = [ whovian ];
"secrets/curse.age".publicKeys = [ whovian ];
}

5
home/secrets/curse.age Normal file
View file

@ -0,0 +1,5 @@
age-encryption.org/v1
-> ssh-ed25519 nNjyyA YJkCAGzmtCrnNTiAzckcxsdxRPebD29OPNLZEej0mX4
L3csYDG+wd18ILISw6ps7TumPnzvc75znIGfGpke/FA
--- qiOWHYgISNePUXoBw8PAM6UAVBsnpcfQ6LP4NbtELaE
[¦Óúæ€ó\Çø]¦U-\5=<06>‰k >qN¨CðÕpù"',¼†•X^4c{0Q#$È5ÀvKi1!|ßöH•“µ*ƒ¢Êñ¯G!—Ûƒ¦ÙBì(ö½4ïNôSß

View file

@ -0,0 +1,6 @@
age-encryption.org/v1
-> ssh-ed25519 nNjyyA T0oUx0+yWUIFF6Tkp0goApgd5h9DgNO81c52VCm38xo
si1r1N5fNISDa7eNRCGWJqbaxC9CvEL0M2vBCLegus0
--- QGYuv1LkTjZGsirDspiyGQ6h977ZDUceo6bj45PeRiI
Yo0áøƺÐV±Ûwh®^Çy<E28098>Ü…­©¡ Î<>ZOÐPNoŠ(qs{ƒ±)á÷Ä
×ôÐ!óËS0âu×<>Èë«ãÕ—5î¨r²<10>Ç

47
system/configuration.nix Normal file
View file

@ -0,0 +1,47 @@
{ lib,
pkgs,
config,
modulesPath,
nixos-wsl,
...
}:
{
imports = [
./packages.nix
./users.nix
];
wsl = {
enable = true;
defaultUser = "whovian";
startMenuLaunchers = false;
wslConf = {
automount = {
root = "/mnt";
};
};
};
networking.hostName = "nixos-wsl";
# Enable nix flakes
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
time.timeZone = "America/New_York";
/*
Add environment.pathsToLink for auto-completion for system packages (e.g. systemd).
Appears to be required due to [GitHub - nix-community/home-manager]:
https://github.com/nix-community/home-manager/blob/c781b28add41b74423ab2e64496d4fc91192e13a/modules/programs/zsh.nix#L348-L358
[/modules/programs/zsh.nix]
https://github.com/nix-community/home-manager/issues/3521#issuecomment-1367197995
[Issue #3521]
*/
environment.pathsToLink = [ "/share/zsh" ];
system.stateVersion = "22.05";
}

37
system/packages.nix Normal file
View file

@ -0,0 +1,37 @@
{ lib, agenix, pkgs, config, modulesPath, ... }:
{
environment.systemPackages = [
pkgs.file
pkgs.xterm
/*
`agenix` is currently added via
"nixos#nixosConfigurations.nixos-wsl.modules.environment.systemPackages"
*/
# agenix.packages.x86_64-linux.default
];
nixpkgs = {
config = {
allowUnfree = true;
};
};
programs = {
zsh = {
enable = true;
};
nano = {
enable = true;
};
/*
I haven't figured out how to get `cdemu` properly working in WSL, so I'm
just going to leave it as `programs.cdemu.enable = false;` for now.
*/
cdemu = {
enable = false;
group = "cdrom";
gui = false;
image-analyzer = false;
};
};
}

22
system/users.nix Normal file
View file

@ -0,0 +1,22 @@
{ lib,
pkgs,
config,
modulesPath,
...
}:
{
users = {
users = {
whovian = {
name = "whovian";
description = "Whovian9369";
extraGroups = [
"wheel"
"cdrom"
];
initialPassword = "abcde"; # I need to log in somehow
shell = pkgs.zsh;
};
};
};
}