many changes

This commit is contained in:
Dmitriy Kholkin 2020-08-05 04:52:30 +04:00
parent de91841c0e
commit c3f757ac1a
15 changed files with 74 additions and 107 deletions

6
flake.lock generated
View File

@ -72,11 +72,11 @@
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1596472492,
"narHash": "sha256-tDghU8H3KU2LP6SY6HtugEBtEdQmPN2TfW8FgS/kCKs=",
"lastModified": 1596554686,
"narHash": "sha256-B+c/xcjp/7vxUm6zVV2SwPalRWYWzxoUOvjGrzlwm7g=",
"owner": "NixOS",
"repo": "nix",
"rev": "24e07c428f21f28df2a41a7a9851d5867f34753a",
"rev": "5b22a2c0d443ce1156f361af2dcb142d270daa6c",
"type": "github"
},
"original": {

View File

@ -60,19 +60,19 @@
};
in genAttrs hosts mkHost;
# legacyPackages.x86_64-linux =
# (builtins.head (builtins.attrValues self.nixosConfigurations)).pkgs;
legacyPackages.x86_64-linux =
(builtins.head (builtins.attrValues self.nixosConfigurations)).pkgs;
# nix run github:serokell/deploy
# Because sudo requires local presence of my Yubikey, we have to manually activate the system
# sudo nix-env -p /nix/var/nix/profiles/system --set /nix/var/nix/profiles/per-user/alukard/system;
# sudo /nix/var/nix/profiles/system/bin/switch-to-configuration switch
# deploy = {
# user = "alukard";
# nodes = builtins.mapAttrs (_: conf: {
# hostname = conf.config.networking.hostName;
# profiles.system.path = conf.config.system.build.toplevel;
# }) self.nixosConfigurations;
# };
deploy = {
user = "alukard";
nodes = builtins.mapAttrs (_: conf: {
hostname = conf.config.networking.hostName;
profiles.system.path = conf.config.system.build.toplevel;
}) self.nixosConfigurations;
};
};
}

View File

@ -1,27 +1,32 @@
# 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, inputs, ... }:
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" "sr_mod" ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/e9d79e40-9a7c-490f-9fc3-8ba36e1ee856";
{ device = "/dev/disk/by-uuid/9affc545-6755-4b5b-b820-36ebb1119330";
fsType = "f2fs";
};
fileSystems."/boot" =
{ device = "/dev/sda1";
{ device = "/dev/disk/by-uuid/4D6C-D3AB";
fsType = "vfat";
};
swapDevices = [ ];
swapDevices = [
{
device = "/dev/disk/by-partuuid/5ff8b0ed-a111-4399-916a-8e49ccb3dd4d";
randomEncryption.enable = true;
}
];
virtualisation.virtualbox.guest.enable = true;
}

View File

@ -1,18 +1,18 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p git
#! nix-shell -i bash -p perl
cd ..
CONFIG_FOLDER=$(pwd)
cd install
ENCRYPT_ROOT=false
FORMAT_BOOT_PARTITION=false
FORMAT_BOOT_PARTITION=true
DEVICE_NAME=Dell-Laptop
MAX_JOBS=8
DEVICE=/dev/nvme0n1
BOOT_PARTITION=/dev/nvme0n1p1
SWAP_PARTITION=/dev/nvme0n1p3
ROOT_PARTITION=/dev/nvme0n1p2
DEVICE_NAME=NixOS-VM
MAX_JOBS=4
DEVICE=/dev/sda
BOOT_PARTITION=/dev/sda1
SWAP_PARTITION=/dev/sda3
ROOT_PARTITION=/dev/sda2
ROOT_NAME=cryptnixos
gdisk $DEVICE
@ -38,14 +38,22 @@ mkdir /mnt/boot
mount $BOOT_PARTITION /mnt/boot
# Create swap
mkswap -L swap $SWAP_PARTITION
# Search swap PARTUUID
SW=$(cut -d'/' -f3 <<< "$SWAP_PARTITION")
SWAP_PARTUUID=$(eval "lsblk -o name,partuuid | grep $SW | awk '{print \$2}'")
# Generate config (hardware)
nixos-generate-config --root /mnt/
# Copy hardware conf into new installation
cp /mnt/etc/nixos/hardware-configuration.nix $CONFIG_FOLDER/hardware-configuration/$DEVICE_NAME.nix
# Change not-detected for flakes
sed -i 's#<nixpkgs/nixos/modules/installer/scan/not-detected.nix>#"${inputs.nixpkgs}/nixos/modules/installer/scan/not-detected.nix"#' $CONFIG_FOLDER/hardware-configuration/$DEVICE_NAME.nix
perl -0777 -pi -e "s#swapDevices.+#swapDevices = [\n {\n device = \"/dev/disk/by-partuuid/$SWAP_PARTUUID\";\n randomEncryption.enable = true;\n }\n ];#" $CONFIG_FOLDER/hardware-configuration/$DEVICE_NAME.nix
# Copy initial system config
cp ./min-config.nix /mnt/etc/nixos/configuration.nix
# Change hostname
sed -i "s#changeme#${DEVICE_NAME}#" /mnt/etc/nixos/configuration.nix
nixos-install -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/840c782d507d60aaa49aa9e3f6d0b0e780912742.tar.gz --max-jobs $MAX_JOBS --no-root-passwd
mkdir -p /mnt/home/alukard/nixos-config
cp -aT $CONFIG_FOLDER /mnt/home/alukard/nixos-config
echo "Installation complete!"
echo "Installation complete!"

View File

@ -9,13 +9,14 @@
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.kernelPackages = pkgs.linuxPackages_latest;
networking = {
hostName = "nixos";
hostName = "changeme";
firewall.enable = false;
networkmanager.enable = false;
wireless = {
enable = true;
enable = false;
userControlled.enable = true;
networks.Alukard_5GHz = {
pskRaw = "feee27000fb0d7118d498d4d867416d04d1d9a1a7b5dbdbd888060bbde816fe4";
@ -24,26 +25,34 @@
};
};
programs.gnupg = {
agent.enable = true;
package = pkgs.gnupg;
};
nixpkgs.config = {
allowUnfree = true;
};
nix = {
useSandbox = true;
autoOptimiseStore = true;
optimise.automatic = true;
extraOptions = ''
experimental-features = nix-command flakes
'';
package = pkgs.nixFlakes;
};
i18n = {
consoleFont = "Lat2-Terminus16";
consoleKeyMap = "us";
defaultLocale = "en_US.UTF-8";
i18n.defaultLocale = "en_GB.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "us";
};
time.timeZone = "Europe/Volgograd";
environment.systemPackages = with pkgs; [
wget vim git gnupg
];
environment.systemPackages = with pkgs; [ git ];
users.mutableUsers = false;
users.users.alukard = {

View File

@ -1,11 +0,0 @@
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
name = "nixflk";
nativeBuildInputs = with pkgs; [
git
];
shellHook = ''
'';
}

27
modules/devices.nix Executable file → Normal file
View File

@ -2,7 +2,7 @@
with lib;
with types; {
options = {
device = mkOption { type = strMatching "[A-z]*-[A-z]*"; };
device = mkOption { type = strMatching "[A-z|0-9]*-(Laptop|Workstation|VM)"; };
devices = mkOption { type = attrs; };
deviceSpecific = mkOption { type = attrs; };
};
@ -13,25 +13,21 @@ with types; {
in rec {
isLaptop = (!isNull (builtins.match ".*Laptop" device));
isVM = (!isNull (builtins.match ".*VM" device));
smallScreen = (device == "Dell-Laptop");
isHost = (device == "AMD-Workstation");
isShared = devInfo.isShared;
isSSD = devInfo.drive.type == "ssd";
smallScreen = (device == "Dell-Laptop");
cpu = devInfo.cpu.vendor;
video = devInfo.video;
isSSD = devInfo.drive.type == "ssd";
enableVirtualisation = devInfo.enableVirtualisation;
hostName = if !isNull devInfo.hostName then
devInfo.hostName
else
device;
};
devices = {
AMD-Workstation = {
cpu = {
vendor = "amd";
clock = 3800;
cores = 6;
clock = 3700;
threads = 12;
};
drive = {
type = "ssd";
@ -41,39 +37,36 @@ with types; {
ram = 16;
isShared = false;
enableVirtualisation = true;
hostName = "ataraxia-pc";
};
Dell-Laptop = {
cpu = {
vendor = "intel";
clock = 1600;
cores = 4;
threads = 8;
};
drive = {
type = "ssd";
size = 250;
};
video = "intel";
ram = 8;
ram = 16;
isShared = false;
enableVirtualisation = false;
hostName = "dell-ataraxia";
};
NixOS-VM = {
cpu = {
vendor = "amd";
clock = 3600;
cores = 2;
clock = 3700;
threads = 4;
};
drive = {
type = "ssd";
size = 12;
size = 20;
};
video = "virtualbox";
ram = 4;
isShared = false;
enableVirtualisation = false;
hostName = null;
};
};
};

13
modules/filesystems.nix Executable file → Normal file
View File

@ -90,17 +90,4 @@ with deviceSpecific; {
];
};
};
swapDevices = [
{
device = if device == "AMD-Workstation" then
"/dev/disk/by-partuuid/3c4f9305-ad40-4ed3-b568-f1559f1c845a"
else if device == "Dell-Laptop" then
"/dev/disk/by-partuuid/e979f198-37c4-4a86-8138-e148c3d78447"
else if device == "NixOS-VM" then
"/dev/disk/by-partuuid/4caf1e45-2f1c-4cb2-a914-f2e90961503a"
else
"";
randomEncryption.enable = true;
}
];
}

View File

@ -26,7 +26,7 @@
userControlled.enable = true;
};
firewall.enable = false;
usePredictableInterfaceNames = false;
usePredictableInterfaceNames = true;
hostName = config.device;
};
}

View File

@ -54,6 +54,7 @@
experimental-features = nix-command flakes
'';
# TODO: change?
# package = pkgs.nixFlakes;
package = inputs.nix.packages.x86_64-linux.nix;

View File

@ -38,8 +38,8 @@ with deviceSpecific; {
powerManagement.cpuFreqGovernor =
lib.mkIf config.services.tlp.enable (lib.mkForce null);
services.undervolt = {
enable = (device == "Dell-Laptop");
services.undervolt = lib.mkIf (device == "Dell-Laptop") {
enable = true;
coreOffset = "-120";
gpuOffset = "-54";
};

View File

@ -22,9 +22,6 @@ with deviceSpecific; {
nsswins = false;
securityType = "user";
syncPasswordsByPam = false;
# shares = {
# };
# extraConfig = ''
configText = ''
[global]
server string = samba home server

5
modules/services.nix Executable file → Normal file
View File

@ -5,11 +5,6 @@ in {
services.acpid.enable = true;
# services.btrfs.autoScrub = {
# enable = true;
# interval = "weekly";
# };
services.redshift = {
enable = true;
temperature.day = 5500;

View File

@ -28,14 +28,10 @@
};
security.sudo = {
enable = true;
extraConfig = ''
ALL ALL = (ALL) NOPASSWD: /run/current-system/sw/bin/btrfs fi usage *
'';
# extraConfig = ''
# alukard ALL = (root) NOPASSWD: /run/current-system/sw/bin/nixos-rebuild switch
# '';
};
# nix.requireSignedBinaryCaches = false;
home-manager.useUserPackages = true;
}

View File

@ -1,13 +1,10 @@
{ pkgs ? import <nixpkgs> { } }:
let
configs = "${toString ./.}#nixosConfigurations";
build = "config.system.build";
rebuild = pkgs.writeShellScriptBin "rebuild" ''
if [[ -z $1 ]]; then
echo "Usage: $(basename $0) host {switch|boot|test}"
echo "Usage: $(basename $0) {switch|boot|test}"
else
sudo -E nix shell -vv ${configs}.$1.${build}.toplevel -c switch-to-configuration $2
sudo nixos-rebuild $1 --flake .
fi
'';
in
@ -16,16 +13,6 @@ pkgs.mkShell {
nativeBuildInputs = with pkgs; [
git
git-crypt
nixFlakes
rebuild
gnupg
];
shellHook = ''
PATH=${
pkgs.writeShellScriptBin "nix" ''
${pkgs.nixFlakes}/bin/nix --option experimental-features "nix-command flakes ca-references" "$@"
''
}/bin:$PATH
'';
}