This commit is contained in:
Michael Thomas 2022-01-17 11:16:14 -05:00
commit 982718bc92
19 changed files with 205 additions and 84 deletions

28
flake.lock generated
View File

@ -7,43 +7,43 @@
]
},
"locked": {
"lastModified": 1627649712,
"narHash": "sha256-AJBasvMKpsyJmCLdjroBElCHY5AlalbVy+XY5vjbgXc=",
"lastModified": 1639871969,
"narHash": "sha256-6feWUnMygRzA9tzkrfAzpA5/NBYg75bkFxnqb1DtD7E=",
"owner": "rycee",
"repo": "home-manager",
"rev": "b39647e52ed3c0b989e9d5c965e598ae4c38d7ef",
"rev": "697cc8c68ed6a606296efbbe9614c32537078756",
"type": "github"
},
"original": {
"owner": "rycee",
"ref": "release-21.05",
"ref": "release-21.11",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1629033443,
"narHash": "sha256-Vo3TvQvR5hsd3incx/xOt6GFgTm651CYVauHS/irOFo=",
"lastModified": 1642190797,
"narHash": "sha256-cxeEEAtfIACnm8sV1oz0xlNp9IVk10Fxcc09ggoEZuo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "8ac785da9843aa110caeed6c912875e46a415a11",
"rev": "3ddd960a3b575bf3230d0e59f42614b71f9e0db9",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-21.05",
"ref": "nixos-21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nur": {
"locked": {
"lastModified": 1629143403,
"narHash": "sha256-Z57DBF3MUTqTnJyYjqEN+DNZLrVukEJJotcxYPHNR/M=",
"lastModified": 1642392502,
"narHash": "sha256-ZRgwagDhwT5eQgTSqhupXz3ugQmFat0836d5Hh8ZK4Q=",
"owner": "nix-community",
"repo": "NUR",
"rev": "79a06a9145c61960dd4b5c2eda67e26276976db1",
"rev": "8993a1cfc2d6ed69725788a2ccafbe8cde0510e3",
"type": "github"
},
"original": {
@ -62,11 +62,11 @@
},
"unstable": {
"locked": {
"lastModified": 1629048390,
"narHash": "sha256-do7HuXFSKyj4ulMlRvGigNZCqOaGD9i0M3OLkFQgEAc=",
"lastModified": 1642104392,
"narHash": "sha256-m71b7MgMh9FDv4MnI5sg9MiBVW6DhE1zq+d/KlLWSC8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e41ba38114055832e5ba4a851e9c00149eef3e4a",
"rev": "5aaed40d22f0d9376330b6fa413223435ad6fee5",
"type": "github"
},
"original": {

View File

@ -2,16 +2,16 @@
description = "Michael Thomas's NixOS configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nur.url = "github:nix-community/NUR";
home-manager = {
url = "github:rycee/home-manager/release-21.05";
url = "github:rycee/home-manager/release-21.11";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nur.url = "github:nix-community/NUR";
};
outputs = inputs: {
@ -39,6 +39,58 @@
specialArgs = { inherit inputs; };
};
work = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./modules/containers.nix
./modules/nix.nix
./modules/vscode-server.nix
./machines/work/configuration.nix
];
specialArgs = { inherit inputs; };
};
};
homeConfigurations = {
nixos = inputs.home-manager.lib.homeManagerConfiguration {
system = "x86_64-linux";
homeDirectory = "/home/michael";
username = "michael";
stateVersion = "21.05";
configuration = { config, pkgs, ... }:
{
nixpkgs.config = {
allowUnfree = true;
};
programs.home-manager.enable = true;
imports = [
./user/environments/nixos/home.nix
];
};
};
wsl = inputs.home-manager.lib.homeManagerConfiguration {
system = "x86_64-linux";
homeDirectory = "/home/michael";
username = "michael";
stateVersion = "21.05";
configuration = { config, pkgs, ... }:
{
nixpkgs.config = {
allowUnfree = true;
};
programs.home-manager.enable = true;
imports = [
./user/environments/wsl/home.nix
];
};
};
};
};
}

View File

@ -10,25 +10,7 @@
./hardware-configuration.nix
];
# Auto cleanup
nix = {
package = pkgs.nixUnstable;
extraOptions = ''
experimental-features = nix-command flakes
'';
autoOptimiseStore = true;
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
};
nixpkgs.config = {
allowUnfree = true;
};
networking.hostName = "nixos"; # Define your hostname.
networking.hostName = "kitchen-nixos"; # Define your hostname.
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config

View File

@ -10,24 +10,6 @@
./hardware-configuration.nix
];
# Auto cleanup
nix = {
package = pkgs.nixUnstable;
extraOptions = ''
experimental-features = nix-command flakes
'';
autoOptimiseStore = true;
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
};
nixpkgs.config = {
allowUnfree = true;
};
# Set your time zone.
time.timeZone = "America/New_York";

View File

@ -0,0 +1,61 @@
{ lib, pkgs, config, modulesPath, ... }:
with lib;
let
defaultUser = "michael";
syschdemd = import ./syschdemd.nix { inherit lib pkgs config defaultUser; };
in
{
imports = [
"${modulesPath}/profiles/minimal.nix"
];
# WSL is closer to a container than anything else
boot.isContainer = true;
environment.etc.hosts.enable = false;
environment.etc."resolv.conf".enable = false;
time.timeZone = "America/New_York";
programs.adb.enable = true;
networking.dhcpcd.enable = false;
# Proxychains
programs.proxychains = {
enable = true;
proxies.main = {
enable = true;
type = "http";
host = "172.21.32.1";
port = 1080;
};
};
users.users.${defaultUser} = {
isNormalUser = true;
extraGroups = [ "wheel" "docker" ];
shell = pkgs.zsh;
};
users.users.root = {
shell = "${syschdemd}/bin/syschdemd";
# Otherwise WSL fails to login as root with "initgroups failed 5"
extraGroups = [ "root" ];
};
security.sudo.wheelNeedsPassword = false;
# Disable systemd units that don't make sense on WSL
systemd.services."serial-getty@ttyS0".enable = false;
systemd.services."serial-getty@hvc0".enable = false;
systemd.services."getty@tty1".enable = false;
systemd.services."autovt@".enable = false;
systemd.services.firewall.enable = false;
systemd.services.systemd-resolved.enable = false;
systemd.services.systemd-udevd.enable = false;
# Don't allow emergency mode, because we don't have a console.
systemd.enableEmergencyMode = false;
}

View File

@ -0,0 +1,15 @@
{ lib, pkgs, config, defaultUser, ... }:
pkgs.substituteAll {
name = "syschdemd";
src = ./syschdemd.sh;
dir = "bin";
isExecutable = true;
buildInputs = with pkgs; [ daemonize ];
inherit (pkgs) daemonize;
inherit defaultUser;
inherit (config.security) wrapperDir;
fsPackagesPath = lib.makeBinPath config.system.fsPackages;
}

View File

@ -0,0 +1,26 @@
#! @shell@
set -e
sw="/nix/var/nix/profiles/system/sw/bin"
systemPath=`${sw}/readlink -f /nix/var/nix/profiles/system`
# Needs root to work
if [[ $EUID -ne 0 ]]; then
echo "[ERROR] Requires root! :( Make sure the WSL default user is set to root"
exit 1
fi
if [ ! -e "/run/current-system" ]; then
/nix/var/nix/profiles/system/activate
fi
if [ ! -e "/run/systemd.pid" ]; then
PATH=/run/current-system/systemd/lib/systemd:@fsPackagesPath@ \
LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive \
@daemonize@/bin/daemonize /run/current-system/sw/bin/unshare -fp --mount-proc systemd
/run/current-system/sw/bin/pgrep -xf systemd > /run/systemd.pid
fi
userShell=$($sw/getent passwd @defaultUser@ | $sw/cut -d: -f7)
exec $sw/nsenter -t $(< /run/systemd.pid) -p -m --wd="$PWD" -- @wrapperDir@/su -s $userShell @defaultUser@ "$@"

View File

@ -7,6 +7,7 @@
./flatpak.nix
./fonts.nix
./gnome.nix
./nix.nix
./sound.nix
];
}

21
modules/nix.nix Normal file
View File

@ -0,0 +1,21 @@
{ pkgs, ... }:
{
nix = {
extraOptions = ''
experimental-features = flakes nix-command
'';
# this is required until nix 2.4 is released
package = pkgs.nixUnstable;
autoOptimiseStore = true;
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
};
nixpkgs.config = {
allowUnfree = true;
};
}

View File

@ -0,0 +1,7 @@
{
imports = [
(fetchTarball "https://github.com/msteen/nixos-vscode-server/tarball/master")
];
services.vscode-server.enable = true;
}

View File

@ -2,7 +2,6 @@
{
imports = [
../../modules/home-manager.nix
../../modules/dev.nix
../../modules/fonts.nix
../../modules/git.nix
@ -13,9 +12,6 @@
];
home.packages = with pkgs; [
neofetch
fortune
google-chrome
firefox
foxitreader
];

View File

@ -2,7 +2,7 @@
{
imports = [
../../modules/home-manager.nix
../../modules/dev.nix
../../modules/git.nix
../../modules/zsh.nix
];

View File

@ -1,3 +0,0 @@
{
allowUnfree = true;
}

View File

@ -1,20 +0,0 @@
{ config, pkgs, ... }:
{
imports = [
../../modules/home-manager.nix
../../modules/fonts.nix
../../modules/git.nix
../../modules/git_nixos.nix
../../modules/gnome.nix
../../modules/dev.nix
../../modules/vscode.nix
../../modules/zsh.nix
];
home.packages = with pkgs; [
neofetch
fortune
];
}

View File

@ -41,6 +41,7 @@
enableZshIntegration = true;
settings = {
character.success_symbol = "[](green)";
character.error_symbol = "[](red)";
};
};
}