From 2add7857f2494a5132dda7a39c5580e647ed8e30 Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Mon, 27 Nov 2023 09:25:12 +0100 Subject: [PATCH] update system --- ctl.sh | 44 ++++++++++++++++--- os/flake.nix | 10 +++-- os/{hw => hardware}/lenovo-thinkpad-e14.nix | 2 + os/system/base.nix | 2 - os/system/boot.nix | 1 + os/system/desktop/gnome.nix | 9 ++++ os/system/{xserver.nix => desktop/plasma.nix} | 0 os/system/network.nix | 10 +++++ os/system/packages.nix | 7 +++ os/system/virtualisation.nix | 11 ++++- os/users/demo.nix | 6 +++ os/users/master.nix | 8 ++++ shell/python.nix | 19 ++++++++ 13 files changed, 116 insertions(+), 13 deletions(-) rename os/{hw => hardware}/lenovo-thinkpad-e14.nix (95%) create mode 100644 os/system/desktop/gnome.nix rename os/system/{xserver.nix => desktop/plasma.nix} (100%) create mode 100644 shell/python.nix diff --git a/ctl.sh b/ctl.sh index a7adc03..ae16b44 100755 --- a/ctl.sh +++ b/ctl.sh @@ -12,6 +12,11 @@ ## gc Garbage collect old generations ## vm Build and run as VM ## +## ~> vm +## +## build Build virtual machine +## run Run virtual machine +## ## ~> store ## ## gc Collecting garbage in nix-store @@ -22,6 +27,13 @@ ## ## run NAME Run a nix-shell from ./shell/ +RED="31" +GREEN="32" +GREENBLD="\e[1;${GREEN}m" +REDBOLD="\e[1;${RED}m" +REDITALIC="\e[3;${RED}m" +EC="\e[0m" + function info { clear cat motd @@ -31,15 +43,16 @@ function info { function os { function test { - sudo nixos-rebuild --flake ./os#nixos test + sudo nixos-rebuild --flake ./os#${1} test } function rebuild { echo "Rebuild OS config: ${1}" sudo nixos-rebuild --flake ./os#${1} switch } function upgrade { - echo "Upgrade channels and rebuild OS" - sudo nixos-rebuild --upgrade --flake ./os#nixos switch + echo "Upgrade channels and rebuild ${1}" + sudo nix-channel --update + sudo nixos-rebuild --upgrade --flake ./os#${1} switch } function changes { nix profile diff-closures --profile /nix/var/nix/profiles/system @@ -48,10 +61,17 @@ function os { sudo nix-collect-garbage -d sudo nixos-rebuild switch } - function vm { - echo "Build and run configuration as VM" - rm *.qcow2 - nixos-rebuild build-vm --flake ./os#nixos && result/bin/run-*-vm + ${@} +} + +function vm { + function build { + echo "Build configuration ${1} as VM" + #rm *.qcow2 + nixos-rebuild build-vm --flake ./os#${1} + } + function run { + result/bin/run-*-vm } ${@} } @@ -78,4 +98,14 @@ function shell { ${@} } +function repl { + info + echo -e "\n${REDBOLD}Enter command...${EC}" + read -p '~> '; + clear + ./ctl.sh ${REPLY} + read -p "Press any key to continue." + repl +} + ${@:-info} diff --git a/os/flake.nix b/os/flake.nix index 387a1f3..d814a97 100644 --- a/os/flake.nix +++ b/os/flake.nix @@ -14,19 +14,23 @@ modules = [ home-manager.nixosModules.home-manager ./configuration.nix - ./hw/lenovo-thinkpad-e14.nix + ./hardware/lenovo-thinkpad-e14.nix ./system/base.nix + ./system/packages.nix + ./system/desktop/plasma.nix ./users/demo.nix ./users/master.nix ]; }; - testos = nixpkgs.lib.nixosSystem { + gnome = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ home-manager.nixosModules.home-manager ./configuration.nix - ./hw/lenovo-thinkpad-e14.nix + ./hardware/lenovo-thinkpad-e14.nix ./system/base.nix + ./system/packages.nix + ./system/desktop/gnome.nix ./users/demo.nix ./users/master.nix ]; diff --git a/os/hw/lenovo-thinkpad-e14.nix b/os/hardware/lenovo-thinkpad-e14.nix similarity index 95% rename from os/hw/lenovo-thinkpad-e14.nix rename to os/hardware/lenovo-thinkpad-e14.nix index eb883ee..9e68741 100644 --- a/os/hw/lenovo-thinkpad-e14.nix +++ b/os/hardware/lenovo-thinkpad-e14.nix @@ -40,4 +40,6 @@ nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.bluetooth.enable = true; + hardware.ledger.enable = true; } diff --git a/os/system/base.nix b/os/system/base.nix index 77d157b..ef268d1 100644 --- a/os/system/base.nix +++ b/os/system/base.nix @@ -5,8 +5,6 @@ ./i18n.nix ./network.nix ./sound.nix - ./xserver.nix ./virtualisation.nix - ./packages.nix ]; } diff --git a/os/system/boot.nix b/os/system/boot.nix index 35319d6..313df61 100644 --- a/os/system/boot.nix +++ b/os/system/boot.nix @@ -2,4 +2,5 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; + boot.supportedFilesystems = [ "ntfs" ]; } diff --git a/os/system/desktop/gnome.nix b/os/system/desktop/gnome.nix new file mode 100644 index 0000000..41f8c0b --- /dev/null +++ b/os/system/desktop/gnome.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: { + services.xserver = { + enable = true; + layout = "ch"; + xkbVariant = ""; + displayManager.gdm.enable = true; + desktopManager.gnome.enable = true; + }; +} diff --git a/os/system/xserver.nix b/os/system/desktop/plasma.nix similarity index 100% rename from os/system/xserver.nix rename to os/system/desktop/plasma.nix diff --git a/os/system/network.nix b/os/system/network.nix index 916c038..82326c3 100644 --- a/os/system/network.nix +++ b/os/system/network.nix @@ -2,6 +2,7 @@ networking = { hostName = "nixos"; nameservers = [ "192.168.1.1" "9.9.9.9" "2620:fe::fe" ]; + #nameservers = [ "127.0.0.1" ]; networkmanager = { enable = true; dns = "none"; @@ -16,4 +17,13 @@ ]; }; }; + # services.dnsmasq = { + # enable = true; + # resolveLocalQueries = true; + # servers = [ + # ''/.mesh.dcentral.systems/10.101.0.7'' + # ''9.9.9.9'' + # ''8.8.8.8'' + # ]; + # }; } diff --git a/os/system/packages.nix b/os/system/packages.nix index 7ba50dd..6b964db 100644 --- a/os/system/packages.nix +++ b/os/system/packages.nix @@ -6,6 +6,7 @@ home-manager.useUserPackages = true; services.printing.enable = true; + services.blueman.enable = true; programs.mtr.enable = true; programs.gnupg.agent = { @@ -22,6 +23,8 @@ gnumake pinentry direnv + dnsutils + netcat vim gcc unzip @@ -31,5 +34,9 @@ remmina docker-buildx appimage-run + gimp ]; + services.logind.extraConfig = '' + RuntimeDirectorySize=20G + ''; } diff --git a/os/system/virtualisation.nix b/os/system/virtualisation.nix index 1f712ec..01a776d 100644 --- a/os/system/virtualisation.nix +++ b/os/system/virtualisation.nix @@ -1,3 +1,12 @@ { pkgs, ... }: { - virtualisation.docker.enable = true; + virtualisation = { + docker.enable = true; + # following configuration is added only when building VM with build-vm + vmVariant = { + virtualisation = { + memorySize = 2048; + cores = 2; + }; + }; + }; } diff --git a/os/users/demo.nix b/os/users/demo.nix index 0ee1cf8..b92b53c 100644 --- a/os/users/demo.nix +++ b/os/users/demo.nix @@ -2,4 +2,10 @@ users.users.demo.isNormalUser = true; users.users.demo.initialPassword = "demo"; system.stateVersion = "23.05"; + + home-manager.users.demo = { + home.stateVersion = "23.05"; + home.username = "demo"; + home.homeDirectory = "/home/demo"; + }; } diff --git a/os/users/master.nix b/os/users/master.nix index 4e42fbd..cbb07a4 100644 --- a/os/users/master.nix +++ b/os/users/master.nix @@ -15,6 +15,10 @@ home.packages = with pkgs; [ plasma5Packages.bismuth kdeconnect + kcalc + filelight + gparted + veracrypt nerdfonts tmux btop @@ -29,6 +33,10 @@ kubectl chromium obsidian + libreoffice-qt + hunspell + hunspellDicts.de_CH + imagemagick ]; programs = { diff --git a/shell/python.nix b/shell/python.nix new file mode 100644 index 0000000..6fcadf5 --- /dev/null +++ b/shell/python.nix @@ -0,0 +1,19 @@ +let + unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) { }; +in +{ pkgs ? import { } }: +pkgs.mkShell { + buildInputs = with pkgs; [ + stdenv + gnumake + cmake + python311Full + python310Packages.nltk + python310Packages.pip + conda + poetry + ninja + nodejs + ]; + LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib"; +}