Minor changes

Untested VF2 config, basic "user", option to enable users, option to enable git, basic graphics role, unfinished `router` role, global features

Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
Ivan Bushchik 2023-10-03 17:15:14 +03:00
parent 6889a37771
commit f916ffb2b4
No known key found for this signature in database
GPG key ID: 2F16FBF3262E090C
26 changed files with 530 additions and 380 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
asahi* asahi*
.key .key
*.DS_Store

View file

@ -24,16 +24,16 @@ nix build path:{{REPO_PATH}}#nixosConfigurations.HOST.config.system.build.sdImag
nixos-rebuild switch --flake path:/etc/nixos nixos-rebuild switch --flake path:/etc/nixos
``` ```
Apple Silicon hosts require additional `--impure` flag for firmware installation. (Firmware should be placed in /etc/nixos/asahi/firmware (ignored by git)). Apple Silicon hosts require additional `--impure` flag for firmware installation. (Firmware should be placed in `/etc/nixos/asahi/firmware` (ignored by git)).
### Hosts configured ### Hosts configured
- stella (Random Ryzen 3 3250U laptop) - celerrime (MacBook Air M2) (coding)
- vetus (iMac 27" 2017) - vetus (iMac 27" 2017) (gaming)
- celerrime (MacBook Air M2) - stella (Random Ryzen 3 3250U laptop) (lite websurfing client)
- celerrime-x (MacBook Air M2 under Darwin) (Needs unifying) - celerrime-x (MacBook Air M2 under Darwin) - Needs unifying + doesn't work - Nix daemon "bootloops"
- rubusidaeus (Raspberry Pi 4B) - rubusidaeus (Raspberry Pi 4B) (small services)
- periculo (StarFive VisionFive2) (as router) - WIP + untested
## Modules ## Modules
@ -70,7 +70,7 @@ curl https://iva.bz/nix | sh
- [ ] iva.bz - [ ] iva.bz
- [ ] ивабус.рф - [ ] ивабус.рф
- Setup "secret" roles (I need them) - Setup "secret" roles (I need them)
- Setup router - Setup router (in progress with `periculo`)
## Copyright ## Copyright

View file

@ -1,6 +1,9 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
{ let
my = import ../.;
secrets = my.secrets { inherit config; };
in {
nix = { nix = {
package = pkgs.nixUnstable; package = pkgs.nixUnstable;
extraOptions = '' extraOptions = ''
@ -10,7 +13,7 @@
auto-optimise-store = true; auto-optimise-store = true;
allowed-users = [ "root" "@wheel" ]; allowed-users = [ "root" "@wheel" ];
trusted-users = [ "root" "@wheel" ]; trusted-users = [ "root" "@wheel" ];
sandbox = true; #sandbox = true;
}; };
gc = { gc = {
automatic = true; automatic = true;
@ -25,12 +28,13 @@
}; };
environment.systemPackages = with pkgs; environment.systemPackages = with pkgs;
[ wget curl git git-crypt neovim python3Minimal nixfmt ] [ wget curl git git-crypt neovim python3Minimal ]
++ lib.optionals pkgs.stdenv.isLinux [ ++ lib.optionals pkgs.stdenv.isLinux [
usbutils usbutils
pciutils pciutils
coreutils-full coreutils
killall killall
]; ];
# Inject secrets through module arguments while evaluating configs.
_module.args.secrets = secrets;
} }

View file

@ -4,7 +4,7 @@ let cfg = config.my.git;
in { in {
options = { my.git.enable = lib.mkEnableOption "Enable git configuration"; }; options = { my.git.enable = lib.mkEnableOption "Enable git configuration"; };
config = lib.mkIf (cfg.enable) { config = lib.mkIf (cfg.enable && config.my.users.ivabus.enable) {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.users.ivabus = { home-manager.users.ivabus = {

View file

@ -7,13 +7,13 @@ in {
}; };
config = lib.mkIf (cfg.enable) { config = lib.mkIf (cfg.enable) {
networking.wireless.iwd.enable = true; networking.wireless.iwd.enable = lib.mkDefault true;
environment.systemPackages = with pkgs; [ lm_sensors ]; environment.systemPackages = with pkgs; [ lm_sensors ];
hardware.bluetooth.enable = true; hardware.bluetooth.enable = lib.mkDefault true;
services.blueman.enable = true; services.blueman.enable = lib.mkDefault true;
services.tlp.enable = true; services.tlp.enable = lib.mkDefault true;
services.upower.enable = true; services.upower.enable = lib.mkDefault true;
}; };
} }

View file

@ -6,7 +6,7 @@
security = { security = {
lockKernelModules = true; lockKernelModules = true;
protectKernelImage = true; protectKernelImage = true;
allowSimultaneousMultithreading = false; allowSimultaneousMultithreading = lib.mkDefault false;
forcePageTableIsolation = true; forcePageTableIsolation = true;
virtualisation.flushL1DataCache = "always"; virtualisation.flushL1DataCache = "always";
apparmor = { apparmor = {

View file

@ -1,8 +1,22 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, secrets, ... }:
let my = import ../.; let
cfg = config.my.users;
keys = [
# celerrime-x
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC6HY6er37FUz2tPQnwq5SUQZ5KHmMpGQA5yNlxPOyoCV+uvdx/cU8KF7jlFoyBC9xf2FvNyB8H1MZ6t2eUs4m/pVMpoBbNSTZLSxlvv2n4HuxL2Sg3qPdioJOyxDfnXA4OIZ+Tc+z4zM3ZnPJm1ccGW7W+YPhZ7GhBpl5wlMw+m06dCt8wfdDA4fuf4brnLt1ZMs4aOtVM8u4ZEtMs3IVXVUgtRH5m0RXZ94s7RkrUHhl2UOkOclhkQOiQop9RuJMjpi+iYkDYCniuGCKcKPrmi1+qicKM8KyrYGqR7FkUvzr+H8XtJXu++Kvmjcn54jDYqM4sq/MNL2rf8QaIUGLwiq2ljH2dGamElvElWZoXQBGPp4L80IEbaMVISIcvcNj+8cKW3rPvEUK5iT8jCkIOUwm1oo70YawS5VXTPLDsZif12QduTcJhVJekEaP0ZSifO52zeJksj0adwiEMJPqm7bIk5Y+9dCbQH7PtkWY4Tw3bdGNsYnTXC80MeEfrIKE= ivabus@celerrime-x"
# Celerrime
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCgZJjP2BRycxcR53sriaityzT24f+umMO8iz/xUvWRUJpgwA4WJyqgKwxuIhKYPUZ7e3H/vVPrt3ZqAaqoFM7OildtcXyRskwinuAxE6lhOEE69s1M3iqCXbrTM9YluMlrvf7yd4edInH0jdlCTwuZOY+yisrGU+nOpSSuJgcwlme2fv1pQtKgTQpqz1GflIaXm5415Do4okanNlfuAJXix7ic0PkaLN0gTtONqwJR1W3hkF8hnlHV49t8QvrJHgQptbVdDgd9f96+a6OL6y/6rixnEU23yuC29lWxSwrixwC0xY+/CjhMlDzXqvePG55vC4K5UQypKcvMOCLV/0z9s5m0ca5mvS9eqPDcUj2+9r7VFaL0IdZl4i7eG9JJSS4h/22Or7CdU9Dv0kiMYP3HLiihjS/lrQVEEYpEMr3DmhSnij5DeGZFmMRM2UN5ZqR7/QhkslhQg340ik6ZENjpxuQ9rQino5XRK52DoUiLHleKI/ibBHQ4LiREvX9muyM= ivabus@celerrime"
];
in rec { in rec {
users.mutableUsers = false; options.my.users = {
ivabus.enable = lib.mkEnableOption "Enable ivabus user";
user.enable = lib.mkEnableOption "Enable general-purpose user";
};
config = lib.mkMerge [
(lib.mkIf (cfg.ivabus.enable) {
my.features.secrets = lib.mkForce true;
users.groups.ivabus = { gid = 1000; }; users.groups.ivabus = { gid = 1000; };
users.users.ivabus = { users.users.ivabus = {
@ -17,23 +31,35 @@ in rec {
htop htop
]; ];
shell = pkgs.zsh; shell = pkgs.zsh;
openssh.authorizedKeys.keys = [ openssh.authorizedKeys.keys = keys;
# celerrime-x hashedPassword = secrets.hashed-password;
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC6HY6er37FUz2tPQnwq5SUQZ5KHmMpGQA5yNlxPOyoCV+uvdx/cU8KF7jlFoyBC9xf2FvNyB8H1MZ6t2eUs4m/pVMpoBbNSTZLSxlvv2n4HuxL2Sg3qPdioJOyxDfnXA4OIZ+Tc+z4zM3ZnPJm1ccGW7W+YPhZ7GhBpl5wlMw+m06dCt8wfdDA4fuf4brnLt1ZMs4aOtVM8u4ZEtMs3IVXVUgtRH5m0RXZ94s7RkrUHhl2UOkOclhkQOiQop9RuJMjpi+iYkDYCniuGCKcKPrmi1+qicKM8KyrYGqR7FkUvzr+H8XtJXu++Kvmjcn54jDYqM4sq/MNL2rf8QaIUGLwiq2ljH2dGamElvElWZoXQBGPp4L80IEbaMVISIcvcNj+8cKW3rPvEUK5iT8jCkIOUwm1oo70YawS5VXTPLDsZif12QduTcJhVJekEaP0ZSifO52zeJksj0adwiEMJPqm7bIk5Y+9dCbQH7PtkWY4Tw3bdGNsYnTXC80MeEfrIKE= ivabus@celerrime-x"
# Stella
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDXWPxd1uVVxEARVezy0s0LZ9fC/Mif6s218oNWDyJNqZMnAiaMwwP/mGHqCy1OXFCb8/5Kv3AM+z6sxY4mIvyXhx3lPW841HoOlJxR+JQ50qgxon/oCXjKFVMZjFptRtexgQLhubhjyINagj7T/K6UjsfC9sIG5DUJdem0O8ZD/8EqvIrkeNGP52klJM3sR4vhXMNwOIPkukNOMq+OLXgAaCXRImc53N+Whi/tCaxxr/Nen5CVGo9raAekRKaiBLKvgboXYnxzNFxiecUe7mqPbyE2bcnJ+rDC7UlwrNYGyIQ/8POjQwbanFxT4UJhS5ib6/hSpia0eYaSiutBqU3fQcIXrmTQWOrGPdrUsLHw5xGMfwnPmoDFMYHdcchU0v6QijbrHrsqVV/bikWoQF4JT7PCwOejfVowOioPghvW2u34gTyMKPkueaMk0w8Jq45V0meneyN5SbobqZX3XFze4Uz3BN8nuiZB6pFRPv0eKLqEqX8+nST9uQDBkqKTvwE= ivabus@stella"
# Celerrime
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCgZJjP2BRycxcR53sriaityzT24f+umMO8iz/xUvWRUJpgwA4WJyqgKwxuIhKYPUZ7e3H/vVPrt3ZqAaqoFM7OildtcXyRskwinuAxE6lhOEE69s1M3iqCXbrTM9YluMlrvf7yd4edInH0jdlCTwuZOY+yisrGU+nOpSSuJgcwlme2fv1pQtKgTQpqz1GflIaXm5415Do4okanNlfuAJXix7ic0PkaLN0gTtONqwJR1W3hkF8hnlHV49t8QvrJHgQptbVdDgd9f96+a6OL6y/6rixnEU23yuC29lWxSwrixwC0xY+/CjhMlDzXqvePG55vC4K5UQypKcvMOCLV/0z9s5m0ca5mvS9eqPDcUj2+9r7VFaL0IdZl4i7eG9JJSS4h/22Or7CdU9Dv0kiMYP3HLiihjS/lrQVEEYpEMr3DmhSnij5DeGZFmMRM2UN5ZqR7/QhkslhQg340ik6ZENjpxuQ9rQino5XRK52DoUiLHleKI/ibBHQ4LiREvX9muyM= ivabus@celerrime"
];
hashedPassword = my.secrets.hashed-password;
}; };
programs.gnupg.agent.enable = true;
})
(lib.mkIf (cfg.user.enable) {
users.users.user = {
isNormalUser = true;
group = "users";
extraGroups = [ "video" "audio" "networkmanager" ];
uid = 1001;
packages = with pkgs; [
tree
neofetch # I use NixOS BTW
duf
htop
];
shell = pkgs.zsh;
openssh.authorizedKeys.keys = keys;
password = "12345";
};
})
({
users.mutableUsers = false;
users.users.root = { users.users.root = {
hashedPassword = null; hashedPassword = null;
openssh.authorizedKeys.keys = openssh.authorizedKeys.keys = keys;
users.users.ivabus.openssh.authorizedKeys.keys;
}; };
environment.shells = [ pkgs.zsh ]; environment.shells = [ pkgs.zsh ];
@ -42,9 +68,10 @@ in rec {
promptInit = ""; promptInit = "";
}; };
programs.gnupg.agent.enable = true;
programs.ssh.startAgent = true; programs.ssh.startAgent = true;
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
})
];
} }

View file

@ -1,7 +1,8 @@
rec { rec {
common = import ./common; common = import ./common;
roles = import ./roles; roles = import ./roles;
features = import ./features.nix;
secrets = import ./secrets.nix; secrets = import ./secrets.nix;
modules = { pkgs, ... }: { imports = [ common roles ]; }; modules = { pkgs, ... }: { imports = [ features common roles ]; };
} }

5
features.nix Normal file
View file

@ -0,0 +1,5 @@
{ lib, config, ... }:
let
in {
options.my.features.secrets = lib.mkEnableOption "Enable secrets decrypting";
}

View file

@ -1,153 +0,0 @@
{
"nodes": {
"apple-silicon-support": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1693064156,
"narHash": "sha256-EnZntHnlPqWZIoa593zDV4GSkfbLLAL6VAreMvM6JN4=",
"owner": "tpwrules",
"repo": "nixos-apple-silicon",
"rev": "bef25f9cdfd8513a42c175b88a1cb619e3ef5951",
"type": "github"
},
"original": {
"owner": "tpwrules",
"repo": "nixos-apple-silicon",
"type": "github"
}
},
"flake-compat": {
"locked": {
"lastModified": 1688025799,
"narHash": "sha256-ktpB4dRtnksm9F5WawoIkEneh1nrEvuxb5lJFt1iOyw=",
"owner": "nix-community",
"repo": "flake-compat",
"rev": "8bf105319d44f6b9f0d764efa4fdef9f1cc9ba1c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "flake-compat",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1693208669,
"narHash": "sha256-hHFaaUsZ860wvppPeiu7nJn/nXZjJfnqAQEu9SPFE9I=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "5bac4a1c06cd77cf8fc35a658ccb035a6c50cd2c",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-23.05",
"repo": "home-manager",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1692248770,
"narHash": "sha256-tZeFpETKQGbgnaSIO1AGWD27IyTcBm4D+A9d7ulQ4NM=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "511177ffe8226c78c9cf6a92a7b5f2df3684956b",
"type": "github"
},
"original": {
"owner": "LnL7",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1692913444,
"narHash": "sha256-1SvMQm2DwofNxXVtNWWtIcTh7GctEVrS/Xel/mdc6iY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "18324978d632ffc55ef1d928e81630c620f4f447",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"rev": "18324978d632ffc55ef1d928e81630c620f4f447",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1694062546,
"narHash": "sha256-PiGI4f2BGnZcedP6slLjCLGLRLXPa9+ogGGgVPfGxys=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b200e0df08f80c32974a6108ce431d8a8a5e6547",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-23.05-darwin",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1693985761,
"narHash": "sha256-K5b+7j7Tt3+AqbWkcw+wMeqOAWyCD1MH26FPZyWXpdo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0bffda19b8af722f8069d09d8b6a24594c80b352",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"apple-silicon-support": "apple-silicon-support",
"home-manager": "home-manager",
"nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs_3"
}
},
"rust-overlay": {
"flake": false,
"locked": {
"lastModified": 1686795910,
"narHash": "sha256-jDa40qRZ0GRQtP9EMZdf+uCbvzuLnJglTUI2JoHfWDc=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "5c2b97c0a9bc5217fc3dfb1555aae0fb756d99f9",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View file

@ -12,13 +12,17 @@
apple-silicon-support.url = "github:tpwrules/nixos-apple-silicon"; apple-silicon-support.url = "github:tpwrules/nixos-apple-silicon";
#nixos-vf2 = { url = "path:/root/nixos-vf2"; };
#nixos-vf2 = { url = "github:Snektron/nixos-vf2"; };
nix-darwin = { nix-darwin = {
url = "github:LnL7/nix-darwin/master"; url = "github:LnL7/nix-darwin/master";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = { self, nixpkgs, home-manager, nix-darwin, apple-silicon-support outputs = { self, nixpkgs, home-manager, nix-darwin, apple-silicon-support
# , nixos-vf2
, ... }@inputs: { , ... }@inputs: {
# Stella = Unchartevice 6540 (Ryzen 3 3250U, 16GB RAM) # Stella = Unchartevice 6540 (Ryzen 3 3250U, 16GB RAM)
nixosConfigurations."stella" = nixpkgs.lib.nixosSystem { nixosConfigurations."stella" = nixpkgs.lib.nixosSystem {
@ -52,6 +56,17 @@
]; ];
}; };
# VisionFive 2, 8GB - firewall + router
nixosConfigurations."periculo" = nixpkgs.lib.nixosSystem {
system = "riscv64-linux";
modules = [
#nixos-vf2.nixosModules.sdImage
./hardware/vf2.nix
home-manager.nixosModules.home-manager
./machines/periculo
];
};
# Celerrime under macOS # Celerrime under macOS
darwinConfigurations."celerrime-x" = nix-darwin.lib.darwinSystem { darwinConfigurations."celerrime-x" = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin"; system = "aarch64-darwin";

View file

@ -3,3 +3,4 @@
Contains `portable` configurations for hardware. Contains `portable` configurations for hardware.
`./rpi4.nix` - Raspberry Pi 4 `./rpi4.nix` - Raspberry Pi 4
`./vf2.nix` - StarFive VisionFive 2

60
hardware/vf2.nix Normal file
View file

@ -0,0 +1,60 @@
{ config, pkgs, lib, ... }:
let
overlay = final: super: {
makeModulesClosure = x:
super.makeModulesClosure (x // {
allowMissing = true;
}); # Ignores missing kernel modules (can't build image without this fix)
# Overflow tests fail
diffutils = super.diffutils.override { doCheck = false; };
};
in {
boot = {
kernelParams = [
"console=tty0"
"console=ttyS0,115200"
"earlycon=sbi"
"boot.shell_on_fail"
];
supportedFilesystems = lib.mkForce [ "ext4" ];
initrd.includeDefaultModules = false;
initrd.availableKernelModules = [
"xhci_pci"
"usbhid"
"usb_storage"
"dw_mmc-pltfm"
"dw_mmc-starfive"
"dwmac-starfive"
"spi-dw-mmio"
"mmc_block"
"nvme"
"sdhci"
"sdhci-pci"
"sdhci-of-dwcmshc"
];
loader = {
grub.enable = false;
generic-extlinux-compatible.enable = true;
};
};
systemd.services."serial-getty@hvc0".enable = false;
systemd.services."serial-getty@ttyS0" = {
enable = true;
wantedBy = [ "getty.target" ];
serviceConfig.Restart = "always";
};
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
options = [ "noatime" ];
};
};
sdImage.compressImage = false;
hardware.enableRedistributableFirmware = true;
}

View file

@ -38,8 +38,7 @@
enable = true; enable = true;
promptInit = ""; promptInit = "";
}; };
/* users.users.ivabus.home = "/Users/ivabus";
users.users.ivabus.home = "/Users/ivabus";
users.users.ivabus.openssh.authorizedKeys.keys = [ users.users.ivabus.openssh.authorizedKeys.keys = [
# i should somehow reuse it from common/user.nix # i should somehow reuse it from common/user.nix
# celerrime-x # celerrime-x
@ -54,7 +53,7 @@
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
*/
services.nix-daemon.enable = true; services.nix-daemon.enable = true;
nix.package = lib.mkForce pkgs.nix;
} }

View file

@ -26,6 +26,11 @@ in {
server = { ivabus-dev.enable = false; }; server = { ivabus-dev.enable = false; };
}; };
my.users = {
ivabus.enable = true;
user.enable = false;
};
my.features.secrets = true;
networking.useDHCP = true; networking.useDHCP = true;

View file

@ -21,6 +21,7 @@ in {
devel.enable = true; devel.enable = true;
gaming.enable = true; gaming.enable = true;
graphical.enable = true; graphical.enable = true;
graphical.basic.enable = false;
latex.enable = true; latex.enable = true;
media-client.enable = true; media-client.enable = true;
torrent.enable = true; torrent.enable = true;
@ -29,6 +30,11 @@ in {
server = { ivabus-dev.enable = true; }; server = { ivabus-dev.enable = true; };
}; };
my.users = {
ivabus.enable = true;
user.enable = false;
};
my.features.secrets = true;
networking.useDHCP = true; networking.useDHCP = true;

View file

@ -0,0 +1,54 @@
{ config, pkgs, lib, ... }:
let my = import ../..;
in {
imports = [ my.modules ];
networking.hostName = "periculo";
boot.loader.grub.enable = false;
boot.loader.generic-extlinux-compatible.enable = true;
# All "my" options
my.laptop.enable = false;
my.git.enable = false;
my.roles = {
design.enable = false;
devel.enable = false;
gaming.enable = false;
graphical.enable = false;
latex.enable = false;
media-client.enable = false;
torrent.enable = false;
virtualisation.enable = false;
yggdrasil-client.enable = false;
server = { ivabus-dev.enable = false; };
};
my.users = {
ivabus.enable = true;
user.enable = false;
};
my.features.secrets = true;
my.roles.router = {
enable = false;
interfaces = {
wan = "enp1s0";
lan = "enp2s0";
};
};
# find out interfaces that show onboard
/* networking = {
enp1s0.useDHCP = false;
enp2s0.useDHCP = false;
};
*/
hardware.enableRedistributableFirmware = true;
system.stateVersion = "23.05";
}

View file

@ -29,6 +29,13 @@ in {
server = { ivabus-dev.enable = true; }; server = { ivabus-dev.enable = true; };
}; };
my.users = {
ivabus.enable = true;
user.enable = false;
};
my.features.secrets = true;
networking = { networking = {
useNetworkd = false; useNetworkd = false;
useDHCP = false; useDHCP = false;

View file

@ -7,31 +7,48 @@ in {
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
google-chrome
zoom-us
whatsapp-for-linux
telegram-desktop
];
networking.hostName = "stella"; networking.hostName = "stella";
my.laptop.enable = true; my.laptop.enable = true;
my.git.enable = true; my.git.enable = true;
my.roles = { my.roles = {
design.enable = true; design.enable = false;
devel.enable = true; devel.enable = false;
gaming.enable = true; gaming.enable = false;
graphical.enable = true; graphical.enable = false;
graphical.basic.enable = true;
latex.enable = false; latex.enable = false;
media-client.enable = true; media-client.enable = true;
torrent.enable = true; torrent.enable = false;
virtualisation.enable = true; virtualisation.enable = false;
yggdrasil-client.enable = true; yggdrasil-client.enable = false;
}; };
my.users = {
ivabus.enable = false;
user.enable = true;
};
my.features.secrets = false;
services.xserver.videoDrivers = [ "amdgpu" ]; services.xserver.videoDrivers = [ "amdgpu" ];
boot.initrd.kernelModules = [ "amdgpu" ]; boot.initrd.kernelModules = [ "amdgpu" ];
powerManagement = { powerManagement = {
enable = true; enable = true;
cpuFreqGovernor = "ondemand"; cpuFreqGovernor = "powersave";
}; };
networking.useDHCP = true; # system is very slow without it
security.allowSimultaneousMultithreading = lib.mkForce true;
system.stateVersion = "23.05"; system.stateVersion = "23.05";
} }

View file

@ -1,36 +1,37 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: { config, lib, pkgs, modulesPath, ... }:
{ {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" ];
[ "xhci_pci" "ahci" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" "nct6775" ]; boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
environment.etc = { fileSystems."/" =
"sysconfig/lm_sensors".text = '' { device = "/dev/disk/by-uuid/01106217-beff-4837-87ce-60f36ad0296e";
HWMON_MODULES="lm75"
'';
};
fileSystems."/" = {
device = "/dev/disk/by-uuid/e9d47776-8f25-490b-9ea3-ee80ab9d6110";
fsType = "btrfs"; fsType = "btrfs";
}; };
boot.initrd.luks.devices."cryptroot".device = fileSystems."/boot" =
"/dev/disk/by-uuid/c2e3757b-b29c-4797-9535-084eb71351e9"; { device = "/dev/disk/by-uuid/22B9-FD88";
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/4F73-6FFF";
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = [ ]; swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp1s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View file

@ -21,6 +21,13 @@ in {
yggdrasil-client.enable = true; yggdrasil-client.enable = true;
}; };
my.users = {
ivabus.enable = true;
user.enable = false;
};
my.features.secrets = true;
networking.useDHCP = true; networking.useDHCP = true;
services.xserver.videoDrivers = [ "amdgpu" ]; services.xserver.videoDrivers = [ "amdgpu" ];

View file

@ -6,6 +6,7 @@
./graphical.nix ./graphical.nix
./latex.nix ./latex.nix
./media-client.nix # TODO: media-server ./media-client.nix # TODO: media-server
./router.nix
./ntp-server.nix ./ntp-server.nix
./torrent.nix ./torrent.nix
./virtualisation.nix ./virtualisation.nix

View file

@ -23,6 +23,7 @@ in {
picocom picocom
screen screen
hyperfine hyperfine
nixfmt
]; ];
} }
# Architecture-specific packages and configuration # Architecture-specific packages and configuration
@ -35,8 +36,11 @@ in {
(lib.mkIf (!pkgs.stdenv.isx86_64) { (lib.mkIf (!pkgs.stdenv.isx86_64) {
boot.binfmt.emulatedSystems = [ "x86_64-linux" "i686-linux" ]; boot.binfmt.emulatedSystems = [ "x86_64-linux" "i686-linux" ];
}) })
(lib.mkIf (builtins.currentSystem != "riscv64-linux") {
boot.binfmt.emulatedSystems = [ "riscv64-linux" ];
})
# Install CLion only if we are on x86_64 /* # Install CLion only if we are on x86_64
(lib.mkIf (pkgs.stdenv.isx86_64) { (lib.mkIf (pkgs.stdenv.isx86_64) {
environment.systemPackages = with pkgs; [ jetbrains.clion ]; environment.systemPackages = with pkgs; [ jetbrains.clion ];
}) })
@ -46,5 +50,6 @@ in {
(pkgs.stdenv.isx86_64 || pkgs.stdenv.isAarch64 || pkgs.stdenv.isAarch32) { (pkgs.stdenv.isx86_64 || pkgs.stdenv.isAarch64 || pkgs.stdenv.isAarch32) {
environment.systemPackages = with pkgs; [ vscode ]; environment.systemPackages = with pkgs; [ vscode ];
}) })
*/
]); ]);
} }

View file

@ -2,8 +2,11 @@
let cfg = config.my.roles.graphical; let cfg = config.my.roles.graphical;
in { in {
options.my.roles.graphical.enable = lib.mkEnableOption "Enable GUI"; options.my.roles.graphical.enable = lib.mkEnableOption "Enable GUI (sway)";
config = lib.mkIf (cfg.enable) { options.my.roles.graphical.basic.enable =
lib.mkEnableOption "Enable GUI (MATE)";
config = lib.mkMerge [
(lib.mkIf (cfg.enable) {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
firefox firefox
alacritty alacritty
@ -54,36 +57,6 @@ in {
enable = true; enable = true;
wlr.enable = true; wlr.enable = true;
}; };
services.pipewire = {
enable = true;
alsa.enable = true;
pulse.enable = true;
alsa.support32Bit = true;
};
qt = {
enable = true;
platformTheme = "gtk2";
style = "gtk2";
};
services.dbus.enable = true;
fonts.packages = with pkgs; [
noto-fonts
noto-fonts-cjk
noto-fonts-cjk-sans
noto-fonts-cjk-serif
noto-fonts-emoji
jetbrains-mono
font-awesome
#google-fonts
liberation_ttf
open-sans
roboto
roboto-mono
kochi-substitute
];
environment.sessionVariables.NIXOS_OZONE_WL = environment.sessionVariables.NIXOS_OZONE_WL =
"1"; # Enable wayland for electron "1"; # Enable wayland for electron
home-manager.users.ivabus = { home-manager.users.ivabus = {
@ -118,5 +91,49 @@ in {
x11.defaultCursor = "Catppuccin-Macchiato-Dark-Cursors"; x11.defaultCursor = "Catppuccin-Macchiato-Dark-Cursors";
}; };
}; };
})
(lib.mkIf (cfg.basic.enable) {
environment.systemPackages = with pkgs; [ firefox ubuntu-themes ];
services.xserver.desktopManager.mate.enable = true;
networking.networkmanager.enable = lib.mkForce true;
networking.networkmanager.wifi.backend = "iwd";
programs.nm-applet.enable = true;
services.xserver.displayManager.sddm.enable = true;
services.xserver.enable = true;
services.xserver.layout = "us,ru";
services.xserver.xkbOptions = "grp:alt_shift_toggle";
})
(lib.mkIf (cfg.basic.enable || cfg.enable) {
services.pipewire = {
enable = true;
alsa.enable = true;
pulse.enable = true;
alsa.support32Bit = true;
}; };
qt = {
enable = true;
platformTheme = "gtk2";
style = "gtk2";
};
services.dbus.enable = true;
fonts.packages = with pkgs; [
noto-fonts
noto-fonts-cjk
noto-fonts-cjk-sans
noto-fonts-cjk-serif
noto-fonts-emoji
jetbrains-mono
font-awesome
#google-fonts
liberation_ttf
open-sans
roboto
roboto-mono
kochi-substitute
];
})
];
} }

69
roles/router.nix Normal file
View file

@ -0,0 +1,69 @@
{ config, lib, pkgs, ... }:
let cfg = config.my.roles.router;
in {
options.my.roles.router.enable =
lib.mkEnableOption "Enable router capabilities";
options.my.roles.router.interfaces.wan = lib.mkOption {
type = lib.types.str;
default = "wan0";
description = ''
WAN interface name.
'';
};
options.my.roles.router.interfaces.lan = lib.mkOption {
type = lib.types.str;
default = "lan0";
description = ''
LAN interface name.
'';
};
config = lib.mkIf (cfg.enable) {
boot.kernel.sysctl = lib.mkForce {
"net.ipv4.conf.all.forwarding" = true;
"net.ipv6.conf.all.forwarding" = true;
"net.ipv6.conf.all.accept_ra" = 0;
"net.ipv6.conf.all.autoconf" = 0;
"net.ipv6.conf.all.use_tempaddr" = 0;
# On WAN, allow IPv6 autoconfiguration and tempory address use.
"net.ipv6.conf.${cfg.interfaces.wan}.accept_ra" = 2;
"net.ipv6.conf.${cfg.interfaces.wan}.autoconf" = 1;
};
services = {
avahi = {
enable = true;
allowInterfaces = [ "${cfg.interfaces.lan}" ];
ipv4 = true;
ipv6 = true;
reflector = true;
};
dhcpd4 = {
enable = true;
interfaces = [ "${cfg.interfaces.lan}" ];
extraConfig = ''
option domain-name-servers 1.1.1.1, 8.8.8.8;
option subnet-mask 255.255.255.0;
subnet 192.168.1.0 netmask 255.255.255.0 {
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
interface ${cfg.interfaces.lan};
range 192.168.1.64 192.168.1.254;
}
'';
};
};
networking = {
nat = {
enable = true;
externalInterface = "${cfg.interfaces.wan}";
internalInterfaces = [ "${cfg.interfaces.lan}" ];
internalIPs = [ "192.168.0.0/24" "192.168.1.0" /24 ];
};
};
};
}

View file

@ -1,8 +1,9 @@
{ config, ... }:
let let
canaryHash = builtins.hashFile "sha256" ./secrets/canary; canaryHash = builtins.hashFile "sha256" ./secrets/canary;
expectedHash = expectedHash =
"bc6f38a927602241c5e0996b61ebd3a90d5356ca76dc968ec14df3cd45c6612c"; "bc6f38a927602241c5e0996b61ebd3a90d5356ca76dc968ec14df3cd45c6612c";
in if canaryHash != expectedHash then in if (canaryHash != expectedHash && config.my.features.secrets) then
abort "Secrets are not readable. Have you run `git-crypt unlock`?" abort "Secrets are not readable. Have you run `git-crypt unlock`?"
else { else {
hashed-password = builtins.readFile ./secrets/hashed-password; hashed-password = builtins.readFile ./secrets/hashed-password;