From 6b39084e8d5d55a61fcb4d38f448ac6da0222485 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 21 Oct 2019 21:26:44 +0800 Subject: [PATCH] add nixops files --- nixops/desktop.nix | 101 ++++++++++++++++++ nixops/juno-hardware-configuration.nix | 30 ++++++ nixops/nixops.nix | 5 + .../configuration.nix => nixops/rpi.nix | 9 +- 4 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 nixops/desktop.nix create mode 100644 nixops/juno-hardware-configuration.nix create mode 100644 nixops/nixops.nix rename rpi-etc-nixos/configuration.nix => nixops/rpi.nix (91%) diff --git a/nixops/desktop.nix b/nixops/desktop.nix new file mode 100644 index 0000000..a95a18f --- /dev/null +++ b/nixops/desktop.nix @@ -0,0 +1,101 @@ +{ host }: + +{ config, pkgs, ... }: + +{ + deployment.targetHost = host; + + imports = + [ + (./. + "/${host}-hardware-configuration.nix") + ]; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = host; + + time.timeZone = "Asia/Hong_Kong"; + + # List packages installed in system profile. To search, run: + # $ nix search wget + nixpkgs.config.allowUnfree = true; + environment.systemPackages = with pkgs; [ + wget vim git firefox thunderbird hexchat usbutils pciutils mplayer vlc youtube-dl file lm_sensors cryptsetup audacious acpi + gwenview okular gimp imagemagick + (python3.withPackages(ps: with ps; [ numpy scipy matplotlib qtconsole pypdf2 reportlab pygments regex ])) + texlive.combined.scheme-full mosh psmisc libreoffice-fresh + xc3sprog gtkwave xournal xsane telnet whois transmission-gtk unzip zip inkscape tigervnc gnupg + wireshark qrencode yosys symbiyosys yices z3 boolector cvc4 pavucontrol keepassx poppler_utils + jq ark sublime3 rink qemu_kvm konsole + ]; + + services.openssh.enable = true; + + # Enable CUPS to print documents. + services.printing = { + enable = true; + }; + services.avahi = { + enable = true; + nssmdns = true; + }; + + # Enable sound. + sound.enable = true; + hardware.pulseaudio = { + enable = true; + extraModules = [ pkgs.pulseaudio-modules-bt ]; + package = pkgs.pulseaudioFull; + }; + + i18n.inputMethod = { + enabled = "fcitx"; + fcitx.engines = with pkgs.fcitx-engines; [ table-extra m17n ]; + }; + fonts.fonts = [ pkgs.noto-fonts pkgs.noto-fonts-cjk pkgs.noto-fonts-emoji pkgs.noto-fonts-extra ]; + + # Enable the X11 windowing system. + services.xserver.enable = true; + services.xserver.layout = "us"; + services.xserver.xkbOptions = "eurosign:e"; + + # Enable touchpad support. + services.xserver.libinput.enable = true; + + # Enable the KDE Desktop Environment. + services.xserver.displayManager.sddm.enable = true; + services.xserver.displayManager.sddm.autoLogin.enable = true; + services.xserver.displayManager.sddm.autoLogin.user = "harry"; + services.xserver.desktopManager.plasma5.enable = true; + + hardware.bluetooth.enable = true; + + programs.fish.enable = true; + users.defaultUserShell = pkgs.fish; + users.extraGroups.plugdev = { }; + users.extraUsers.sb = { + isNormalUser = true; + extraGroups = ["wheel" "plugdev" "dialout"]; + }; + users.extraUsers.harry = { + isNormalUser = true; + extraGroups = ["plugdev" "dialout"]; + }; + security.sudo.wheelNeedsPassword = false; + services.udev.packages = [ pkgs.openocd pkgs.hackrf ]; + services.udev.extraRules = '' +ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple" +ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple" + ''; + + nix.binaryCachePublicKeys = ["nixbld.m-labs.hk-1:5aSRVA5b320xbNvu30tqxVPXpld73bhtOeH6uAjRyHc="]; + nix.binaryCaches = ["https://nixbld.m-labs.hk" "https://cache.nixos.org"]; + nix.sandboxPaths = ["/opt"]; + + # This value determines the NixOS release with which your system is to be + # compatible, in order to avoid breaking some software such as database + # servers. You should change this only after NixOS release notes say you + # should. + system.stateVersion = "19.03"; # Did you read the comment? +} diff --git a/nixops/juno-hardware-configuration.nix b/nixops/juno-hardware-configuration.nix new file mode 100644 index 0000000..0564025 --- /dev/null +++ b/nixops/juno-hardware-configuration.nix @@ -0,0 +1,30 @@ +# 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, ... }: + +{ + imports = + [ + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/62a38d9c-452c-4648-be12-6131e95b8276"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/88F6-46F2"; + fsType = "vfat"; + }; + + swapDevices = [ ]; + + nix.maxJobs = lib.mkDefault 8; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; +} diff --git a/nixops/nixops.nix b/nixops/nixops.nix new file mode 100644 index 0000000..14486ad --- /dev/null +++ b/nixops/nixops.nix @@ -0,0 +1,5 @@ +{ + rpi-1 = import ./rpi.nix { host = "rpi-1"; }; + rpi-2 = import ./rpi.nix { host = "rpi-2"; }; + juno = import ./desktop.nix { host = "juno"; }; +} diff --git a/rpi-etc-nixos/configuration.nix b/nixops/rpi.nix similarity index 91% rename from rpi-etc-nixos/configuration.nix rename to nixops/rpi.nix index ac5b203..d26b8fe 100644 --- a/rpi-etc-nixos/configuration.nix +++ b/nixops/rpi.nix @@ -1,13 +1,18 @@ +{ host }: + { config, pkgs, lib, ... }: let m-labs = import (fetchTarball https://nixbld.m-labs.hk/channel/custom/artiq/full/artiq-full/nixexprs.tar.xz) {}; in { + deployment.targetHost = host; + nixpkgs.system = "aarch64-linux"; + boot.loader.grub.enable = false; boot.loader.generic-extlinux-compatible.enable = true; boot.kernelParams = ["cma=32M console=ttyS1,115200n8"]; - + fileSystems = { "/" = { device = "/dev/disk/by-label/NIXOS_SD"; @@ -17,7 +22,7 @@ in services.openssh.enable = true; - networking.hostName = "rpi-1"; + networking.hostName = host; time.timeZone = "Asia/Hong_Kong"; users.extraGroups.plugdev = { };