From ac6e741037a4202fc2259cea6b84edc76296424e Mon Sep 17 00:00:00 2001 From: Chan Wen Xu Date: Sat, 11 Sep 2021 20:05:37 +0800 Subject: [PATCH] Initial Config Commit --- config/aspire.nix | 28 +++++++++++++++++ config/aspire_hardware.nix | 43 ++++++++++++++++++++++++++ config/common.nix | 60 +++++++++++++++++++++++++++++++++++++ config/pkg/os-prober.patch | 47 +++++++++++++++++++++++++++++ flake.lock | 48 +++++++++++++++++++++++++++++ flake.nix | 23 ++++++++++++++ home/home.nix | 12 ++++++++ home/i3.nix | 8 +++++ secrets/secrets.nix | Bin 0 -> 146 bytes 9 files changed, 269 insertions(+) create mode 100644 config/aspire.nix create mode 100644 config/aspire_hardware.nix create mode 100644 config/common.nix create mode 100644 config/pkg/os-prober.patch create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home/home.nix create mode 100644 home/i3.nix create mode 100644 secrets/secrets.nix diff --git a/config/aspire.nix b/config/aspire.nix new file mode 100644 index 0000000..4017c2a --- /dev/null +++ b/config/aspire.nix @@ -0,0 +1,28 @@ +{ config, pkgs, lib, ... }: + +{ + nix.buildCores = 1; + nix.maxJobs = 2; + + nixpkgs.config.allowUnfree = true; + + boot.initrd.luks.devices."cryptroot".device = "/dev/disk/by-uuid/97b23bd6-cca7-499c-9589-a74ce3205731"; + boot.loader.grub = { + enable = true; + version = 2; + device = "/dev/sda"; + useOSProber = true; + }; + + networking = { + hostName = "aspire"; + + # useDHCP is deprecated, disable explicitly. + useDHCP = false; + interfaces.enp2s0f0.useDHCP = true; + }; + + services.xserver.libinput.enable = true; + + system.stateVersion = "21.05"; +} diff --git a/config/aspire_hardware.nix b/config/aspire_hardware.nix new file mode 100644 index 0000000..7e9be96 --- /dev/null +++ b/config/aspire_hardware.nix @@ -0,0 +1,43 @@ +# 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, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "ehci_pci" "ahci" "xhci_pci" "usb_storage" "usbhid" "sd_mod" "sr_mod" "sdhci_pci" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + boot.kernelModules = [ "kvm-intel" "wl" ]; + boot.extraModulePackages = [ config.boot.kernelPackages.broadcom_sta ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/3a5d1853-d44b-4483-b964-62ef2ad25d06"; + fsType = "btrfs"; + options = [ "subvol=@" ]; + }; + + fileSystems."/persist" = + { device = "/dev/disk/by-uuid/3a5d1853-d44b-4483-b964-62ef2ad25d06"; + fsType = "btrfs"; + options = [ "subvol=@persist" ]; + }; + + fileSystems."/nix" = + { device = "/dev/disk/by-uuid/3a5d1853-d44b-4483-b964-62ef2ad25d06"; + fsType = "btrfs"; + options = [ "subvol=@nix" ]; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/2e235b61-281c-481e-936a-918653d2dd06"; + fsType = "ext4"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/1ba34ba4-5007-4669-a7eb-78e516d2d29c"; } + ]; + +} diff --git a/config/common.nix b/config/common.nix new file mode 100644 index 0000000..b15e885 --- /dev/null +++ b/config/common.nix @@ -0,0 +1,60 @@ +{ self, home-manager, ... }: +{ config, pkgs, lib, ... }: + +{ + imports = [ + home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.chanbakjsd = import ../home/home.nix; + } + ]; + + nix.package = pkgs.nixUnstable; + nix.extraOptions = "experimental-features = nix-command flakes"; + + nixpkgs.config.allowUnfree = true; + nixpkgs.config.packageOverrides = pkgs: { + os-prober = pkgs.os-prober.overrideAttrs (ori: { + patches = [ ./pkg/os-prober.patch ]; # OS Prober is awfully slow in detecting Linux distros. + }); + }; + + environment.systemPackages = with pkgs; [ + firefox + git + git-crypt + vim + ]; + + fonts.fonts = with pkgs; [ + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + jetbrains-mono + ]; + + sound.enable = true; + hardware.pulseaudio.enable = true; + + time.timeZone = "Asia/Kuala_Lumpur"; + + networking.networkmanager.enable = true; + networking.dhcpcd.wait = "background"; # Don't wait and immediately go to background. + + services.xserver = { + enable = true; + displayManager.sddm.enable = true; + windowManager.i3.enable = true; + }; + + users = { + mutableUsers = false; # Force all users to be declared + users.chanbakjsd = { + isNormalUser = true; + extraGroups = [ "wheel" "networkmanager" ]; + hashedPassword = self.secrets.passwordHash; + }; + }; + +} diff --git a/config/pkg/os-prober.patch b/config/pkg/os-prober.patch new file mode 100644 index 0000000..868ff97 --- /dev/null +++ b/config/pkg/os-prober.patch @@ -0,0 +1,47 @@ +From f55729aa2b44bb31f44ea7293e359d035eeb4b31 Mon Sep 17 00:00:00 2001 +From: Chan Wen Xu +Date: Sat, 11 Sep 2021 15:47:29 +0800 +Subject: [PATCH 1/1] Skip expensive call + +--- + os-probes/mounted/common/90linux-distro | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +diff --git a/os-probes/mounted/common/90linux-distro b/os-probes/mounted/common/90linux-distro +index 41a5553..cac2368 100755 +--- a/os-probes/mounted/common/90linux-distro ++++ b/os-probes/mounted/common/90linux-distro +@@ -17,7 +17,9 @@ type="$3" + # symlinks we need to also check in $dir/usr/lib* for distributions that + # moved /lib* to /usr and only left symlinks behind. + # TODO: look for ld-linux.so on arches that have it +-if (ls "$dir"/lib*/ld*.so* && [ -d "$dir/boot" ] || ls "$dir"/usr/lib*/ld*.so*) >/dev/null 2>/dev/null; then ++ ++# Avoid expensive search, don't have exotic distros anyways. ++# if (ls "$dir"/lib*/ld*.so* && [ -d "$dir/boot" ] || ls "$dir"/usr/lib*/ld*.so*) >/dev/null 2>/dev/null; then + if [ -e "$dir/etc/os-release" ]; then + short="$(grep ^NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g; s/[[:space:]].*//')" + long="$(grep ^PRETTY_NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g')" +@@ -141,13 +143,14 @@ if (ls "$dir"/lib*/ld*.so* && [ -d "$dir/boot" ] || ls "$dir"/usr/lib*/ld*.so*) + short="Exherbo" + long="Exherbo Linux" + else +- short="Linux" +- long="unknown Linux distribution" ++ exit 1 ++ # short="Linux" ++ # long="unknown Linux distribution" + fi + + label="$(count_next_label "$short")" + result "$partition:$long:$label:linux" + exit 0 +-else +- exit 1 +-fi ++# else ++# exit 1 ++# fi +-- +2.32.0 + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..fb4dfbf --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1631134124, + "narHash": "sha256-C17wJ2HyuFZllJ/PbpFuuDjkzWvg8np9UIAdSrpuwS0=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "039f786e609fdb3cfd9c5520ff3791750c3eaebf", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1631295156, + "narHash": "sha256-jIriDkYUU09njpjvpRiS2/Yy+iKpmalCGJ2HnC41ZSQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "bbbe2b35f736d039884e082ecc6d6e631e126029", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..df74ff6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,23 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, home-manager, ... }@inputs: + { + nixosConfigurations = { + aspire = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + (import ./config/common.nix inputs) + ./config/aspire.nix + ./config/aspire_hardware.nix + ]; + }; + }; + + secrets = import ./secrets/secrets.nix; + }; +} diff --git a/home/home.nix b/home/home.nix new file mode 100644 index 0000000..d9bb2f1 --- /dev/null +++ b/home/home.nix @@ -0,0 +1,12 @@ +{ self, pkgs, ... }: + +{ + services.polybar = { + enable = true; + script = "polybar bar &"; + }; + xsession.windowManager.i3 = { + enable = true; + config = import ./i3.nix; + }; +} diff --git a/home/i3.nix b/home/i3.nix new file mode 100644 index 0000000..491ea9c --- /dev/null +++ b/home/i3.nix @@ -0,0 +1,8 @@ +{ + fonts = { + names = [ "JetBrains Mono" ]; + size = 12.0; + }; + + modifier = "Mod4"; +} diff --git a/secrets/secrets.nix b/secrets/secrets.nix new file mode 100644 index 0000000000000000000000000000000000000000..4d4d1b38a95118a7cb0a282a217c8a81e2a17634 GIT binary patch literal 146 zcmV;D0B!#OM@dveQdv+`0DZq<|F}vW)#!WNs%L<^=Lp>h0gC9rV~QeHolRJK}7YC7AJ6pHKWImQ_mX^kXDalqBK>bO(2jIdJgcx7|{X*eeakNh=`v zE`jsh!HOP$PI=%Ugq6+p?=e$R&O?CNSVMp-WCV~vjl`kwJx4}Op6@K`{Xu4`7&$*j AhX4Qo literal 0 HcmV?d00001