From c636397e6062b4d9471a4b5f4e9cf7d34a257131 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 2 Sep 2023 22:05:18 +0530 Subject: flake: init --- .gitignore | 1 - configuration.nix | 89 ------------------------------------ flake.lock | 27 +++++++++++ flake.nix | 17 +++++++ hosts/cez.nix | 39 ---------------- hosts/cez/configuration.nix | 40 ++++++++++++++++ hosts/cez/hardware-configuration.nix | 38 +++++++++++++++ hosts/common.nix | 86 ++++++++++++++++++++++++++++++++++ hosts/kay.nix | 5 -- hosts/kay/configuration.nix | 10 ++++ hosts/kay/hardware-configuration.nix | 32 +++++++++++++ overlays/default.nix | 4 ++ overlays/dwl-sinan.nix | 12 ----- overlays/dwl-sinan/default.nix | 14 ++++++ overlays/wmenu-cez/default.nix | 12 +++++ overlays/wmenu-sinan.nix | 10 ---- 16 files changed, 280 insertions(+), 156 deletions(-) delete mode 100644 .gitignore delete mode 100644 configuration.nix create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 hosts/cez.nix create mode 100644 hosts/cez/configuration.nix create mode 100644 hosts/cez/hardware-configuration.nix create mode 100644 hosts/common.nix delete mode 100644 hosts/kay.nix create mode 100644 hosts/kay/configuration.nix create mode 100644 hosts/kay/hardware-configuration.nix create mode 100644 overlays/default.nix delete mode 100644 overlays/dwl-sinan.nix create mode 100644 overlays/dwl-sinan/default.nix create mode 100644 overlays/wmenu-cez/default.nix delete mode 100644 overlays/wmenu-sinan.nix diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 577b0a0..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -hardware-configuration.nix diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index 3e76b9e..0000000 --- a/configuration.nix +++ /dev/null @@ -1,89 +0,0 @@ -{ config, pkgs, lib, ... }: - -let - user = config.userdata.user; - groups = config.userdata.groups; -in -{ - imports = [ - ./hardware-configuration.nix # hw scan - ./modules/userdata.nix - ./hosts/cez.nix - ]; - - # boot - boot = { - tmp.useTmpfs = true; - loader = { - timeout = 1; - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; - }; - - # networking - time.timeZone = "Asia/Kolkata"; - - # users - users.users.${user} = { - isNormalUser = true; - extraGroups = [ - "wheel" - "adbusers" - ] ++ groups; - packages = with pkgs; [ - pass - yt-dlp - geoipWithDatabase - dig - nnn - ffmpeg - rtorrent - ps_mem - brightnessctl - ]; - }; - - # system - environment = { - binsh = "${pkgs.dash}/bin/dash"; - shellAliases = { - ls = "ls --color=auto --group-directories-first"; - grep = "grep --color=auto"; - }; - systemPackages = with pkgs; [ - dash - unzip - bc - file - git - htop - curl - neovim - ]; - }; - system.stateVersion = "23.05"; - - # nix - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - nixpkgs.overlays = with builtins; lib.mkIf (pathExists ./overlays) ( - map - (overlay: import ./overlays/${overlay}) - (attrNames (readDir ./overlays)) - ); - - # programs - programs = { - adb.enable = true; - bash.promptInit = '' - PROMPT_COLOR="1;31m" - [ "$UID" -ne 0 ] && - PROMPT_COLOR="1;32m" - - PS1="\[\033[$PROMPT_COLOR\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\\$\[\033[0m\] " - ''; - }; -} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e6cde03 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1693565476, + "narHash": "sha256-ya00zHt7YbPo3ve/wNZ/6nts61xt7wK/APa6aZAfey0=", + "owner": "NixOs", + "repo": "nixpkgs", + "rev": "aa8aa7e2ea35ce655297e8322dc82bf77a31d04b", + "type": "github" + }, + "original": { + "owner": "NixOs", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..93713c0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,17 @@ +{ + description = "reproducible nixos configuration with flakes"; + inputs.nixpkgs.url = "github:NixOs/nixpkgs/nixos-unstable"; + + outputs = { self, nixpkgs }: { + nixosConfigurations = { + cez = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ ./hosts/cez/configuration.nix ]; + }; + kay = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ ./hosts/kay/configuration.nix ]; + }; + }; + }; +} diff --git a/hosts/cez.nix b/hosts/cez.nix deleted file mode 100644 index bf9ffde..0000000 --- a/hosts/cez.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ config, pkgs, ... }: - -let - user = config.userdata.user; -in -{ - imports = [ - ../modules/wayland.nix - ../modules/sshfs.nix - ../modules/dev.nix - ]; - - boot = { - initrd.luks.reusePassphrases = true; - consoleLogLevel = 3; - kernelPackages = pkgs.linuxPackages_latest; - }; - sound = { - enable = true; - extraConfig = '' - defaults.pcm.card 1 - defaults.ctl.card 1 - ''; - }; - - networking = { - hostName = "cez"; - dhcpcd.wait = "background"; - wireless.iwd.enable = true; - }; - - services = { - getty.autologinUser = user; - pipewire = { - enable = true; - pulse.enable = true; - }; - }; -} diff --git a/hosts/cez/configuration.nix b/hosts/cez/configuration.nix new file mode 100644 index 0000000..ac2d2ea --- /dev/null +++ b/hosts/cez/configuration.nix @@ -0,0 +1,40 @@ +{ config, pkgs, ... }: + +let + user = config.userdata.user; +in +{ + imports = [ + ./hardware-configuration.nix + ../../modules/wayland.nix + ../../modules/sshfs.nix + ../common.nix + ]; + + boot = { + initrd.luks.reusePassphrases = true; + consoleLogLevel = 3; + kernelPackages = pkgs.linuxPackages_latest; + }; + sound = { + enable = true; + extraConfig = '' + defaults.pcm.card 1 + defaults.ctl.card 1 + ''; + }; + + networking = { + hostName = "cez"; + dhcpcd.wait = "background"; + wireless.iwd.enable = true; + }; + + services = { + getty.autologinUser = user; + pipewire = { + enable = true; + pulse.enable = true; + }; + }; +} diff --git a/hosts/cez/hardware-configuration.nix b/hosts/cez/hardware-configuration.nix new file mode 100644 index 0000000..70ad4aa --- /dev/null +++ b/hosts/cez/hardware-configuration.nix @@ -0,0 +1,38 @@ +{ modulesPath, ... }: + +{ + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot = { + kernelModules = [ "kvm-amd" ]; + initrd = { + availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usb_storage" + "sd_mod" + "sdhci_pci" + ]; + luks.devices = { + "cryptroot".device = "/dev/disk/by-uuid/445abd75-6887-4b10-8483-a4be94f1fffd"; + "crypthome".device = "/dev/disk/by-uuid/b1f57828-d0c3-4b0b-9d32-5e7e96651eda"; + }; + }; + }; + + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/1df57eaf-50cd-405d-85ef-ccd1f2649227"; + fsType = "ext4"; + }; + "/boot" = { + device = "/dev/disk/by-uuid/EE3C-1135"; + fsType = "vfat"; + }; + "/home" = { + device = "/dev/disk/by-uuid/c6649ef3-f96d-4a11-ae20-d8d937d8a8e4"; + fsType = "ext4"; + }; + }; +} diff --git a/hosts/common.nix b/hosts/common.nix new file mode 100644 index 0000000..56f2953 --- /dev/null +++ b/hosts/common.nix @@ -0,0 +1,86 @@ +{ config, pkgs, lib, ... }: + +let + user = config.userdata.user; + groups = config.userdata.groups; +in +{ + imports = [ + ../modules/userdata.nix + ../modules/dev.nix + ]; + + # boot + boot = { + tmp.useTmpfs = true; + loader = { + timeout = 1; + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + }; + + # networking + time.timeZone = "Asia/Kolkata"; + networking.useDHCP = lib.mkDefault true; + + # users + users.users.${user} = { + isNormalUser = true; + extraGroups = [ + "wheel" + "adbusers" + ] ++ groups; + packages = with pkgs; [ + pass + yt-dlp + geoipWithDatabase + dig + nnn + ffmpeg + rtorrent + ps_mem + brightnessctl + neofetch + ]; + }; + + # system + environment = { + binsh = "${pkgs.dash}/bin/dash"; + shellAliases = { + ls = "ls --color=auto --group-directories-first"; + grep = "grep --color=auto"; + }; + systemPackages = with pkgs; [ + dash + unzip + bc + file + git + htop + curl + neovim + ]; + }; + system.stateVersion = "23.05"; + + # nix + nix.settings.experimental-features = [ + "flakes" + "nix-command" + ]; + nixpkgs.overlays = (import ../overlays); + + # programs + programs = { + adb.enable = true; + bash.promptInit = '' + PROMPT_COLOR="1;31m" + [ "$UID" -ne 0 ] && + PROMPT_COLOR="1;32m" + + PS1="\[\033[$PROMPT_COLOR\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\\$\[\033[0m\] " + ''; + }; +} diff --git a/hosts/kay.nix b/hosts/kay.nix deleted file mode 100644 index 49a17c0..0000000 --- a/hosts/kay.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ pkgs, ... }: - -{ - environment.systemPackages = with pkgs; [ tmux ]; -} diff --git a/hosts/kay/configuration.nix b/hosts/kay/configuration.nix new file mode 100644 index 0000000..8ad42c8 --- /dev/null +++ b/hosts/kay/configuration.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: + +{ + imports = [ + ./hardware-configuration.nix + ../common.nix + ]; + + environment.systemPackages = with pkgs; [ tmux ]; +} diff --git a/hosts/kay/hardware-configuration.nix b/hosts/kay/hardware-configuration.nix new file mode 100644 index 0000000..1583736 --- /dev/null +++ b/hosts/kay/hardware-configuration.nix @@ -0,0 +1,32 @@ +{ modulesPath, ... }: + +{ + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot = { + kernelModules = [ "kvm-intel" ]; + initrd.availableKernelModules = [ + "xhci_pci" + "ehci_pci" + "ahci" + "usb_storage" + "usbhid" + "sd_mod" + ]; + }; + + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/2eeacf49-c51e-4229-bd4a-ae437014725f"; + fsType = "ext4"; + }; + "/boot" = { + device = "/dev/disk/by-uuid/A902-90BB"; + fsType = "vfat"; + }; + "/hdd" = { + device = "/dev/disk/by-uuid/c941edb4-e393-4254-bbef-d1b3728290e9"; + fsType = "ext4"; + }; + }; +} diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..b880f32 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,4 @@ +[ + (import ./dwl-sinan) + (import ./wmenu-cez) +] diff --git a/overlays/dwl-sinan.nix b/overlays/dwl-sinan.nix deleted file mode 100644 index b3c39b0..0000000 --- a/overlays/dwl-sinan.nix +++ /dev/null @@ -1,12 +0,0 @@ -final: prev: { - dwl-sinan = prev.dwl.overrideAttrs (finalAttrs: prevAttrs: - { - pname = prevAttrs.pname + "-sinan"; - src = prev.fetchgit { - url = "https://git.sinanmohd.com/dwl"; - rev = "cadde97ee92381bfc2222bf18cd876526ab8c948"; - hash = "sha256-H2HgOQnQ5Eltz8/OVpKlS2U89aaivg5t63Ie4fembw8="; - }; - } - ); -} diff --git a/overlays/dwl-sinan/default.nix b/overlays/dwl-sinan/default.nix new file mode 100644 index 0000000..ff5c999 --- /dev/null +++ b/overlays/dwl-sinan/default.nix @@ -0,0 +1,14 @@ +final: prev: + +{ + dwl-sinan = prev.dwl.overrideAttrs (finalAttrs: prevAttrs: + { + pname = prevAttrs.pname + "-sinan"; + src = prev.fetchgit { + url = "https://git.sinanmohd.com/dwl"; + rev = "cadde97ee92381bfc2222bf18cd876526ab8c948"; + hash = "sha256-H2HgOQnQ5Eltz8/OVpKlS2U89aaivg5t63Ie4fembw8="; + }; + } + ); +} diff --git a/overlays/wmenu-cez/default.nix b/overlays/wmenu-cez/default.nix new file mode 100644 index 0000000..c304efb --- /dev/null +++ b/overlays/wmenu-cez/default.nix @@ -0,0 +1,12 @@ +final: prev: + +{ + wmenu-sinan = prev.wmenu.overrideAttrs (finalAttrs: prevAttrs: + { + pname = prevAttrs.pname + "-sinan"; + postPatch = '' + sed 's/monospace 10/monospace 13/g' -i main.c + ''; + } + ); +} diff --git a/overlays/wmenu-sinan.nix b/overlays/wmenu-sinan.nix deleted file mode 100644 index c525ab9..0000000 --- a/overlays/wmenu-sinan.nix +++ /dev/null @@ -1,10 +0,0 @@ -final: prev: { - wmenu-sinan = prev.wmenu.overrideAttrs (finalAttrs: prevAttrs: - { - pname = prevAttrs.pname + "-sinan"; - postPatch = '' - sed 's/monospace 10/monospace 13/g' -i main.c - ''; - } - ); -} -- cgit v1.2.3