From 3372af8c035c02824e9ba1b924ecf2d7fa7bf1f7 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Thu, 26 Dec 2024 00:46:15 -0800 Subject: [PATCH] feat: add template --- README.md | 12 +- flake.nix | 8 ++ templates/liminalOS/configuration.nix | 106 ++++++++++++++++++ templates/liminalOS/flake.nix | 33 ++++++ .../liminalOS/hardware-configuration.nix | 59 ++++++++++ templates/liminalOS/home.nix | 25 +++++ 6 files changed, 238 insertions(+), 5 deletions(-) create mode 100755 templates/liminalOS/configuration.nix create mode 100644 templates/liminalOS/flake.nix create mode 100644 templates/liminalOS/hardware-configuration.nix create mode 100644 templates/liminalOS/home.nix diff --git a/README.md b/README.md index b33fb55..4ad588a 100755 --- a/README.md +++ b/README.md @@ -6,17 +6,19 @@ based on [NixOS](https://nixos.org/). Time wasted writing Nix code: ![](https://wakatime.com/badge/user/018dc5b8-ba5a-4572-a38a-b526d1b28240/project/c59b3d5e-0c9c-4bd5-a752-e75522ab0cdc.svg) + [![wakatime](https://wakatime.com/badge/user/018dc5b8-ba5a-4572-a38a-b526d1b28240/project/de5e82f8-8a09-42cb-ae45-9c80f2ab5a41.svg)](https://wakatime.com/badge/user/018dc5b8-ba5a-4572-a38a-b526d1b28240/project/de5e82f8-8a09-42cb-ae45-9c80f2ab5a41) -This repository implements a NixOS module that declares the entire liminalOS +This repository exposes a NixOS module that declares the entire liminalOS operating system. It aims to be an easy way to both set up a brand new system with my opinionated configurations, and also inject into an existing NixOS configuration. -A reference implementation of liminalOS on actual working systems is in +Reference implementations of liminalOS on actual working systems is in [./reference](./reference). -liminalOS is currently in a heavily experimental state, and cannot be consumed -directly without much prior work. Development is ongoing to create a fully -self-contained module. +liminalOS is currently in a heavily experimental state, but it is used in +production every day! + +You can try it with `nix flake init -t github:youwen5/liminalOS#liminalOS`, +which will create a sample configuration flake along with corresponding files. Many have written at length about the virtues of NixOS and _declarative configuration_ and _immutability_ and such. I doubt what I have to say is diff --git a/flake.nix b/flake.nix index dc8b2db..16d9dd8 100755 --- a/flake.nix +++ b/flake.nix @@ -189,6 +189,14 @@ ]; }; }; + + templates = rec { + liminalOS = { + path = ./templates/liminalOS; + description = "Barebones configuration of liminalOS"; + }; + default = liminalOS; + }; }; perSystem = { diff --git a/templates/liminalOS/configuration.nix b/templates/liminalOS/configuration.nix new file mode 100755 index 0000000..d48b3bc --- /dev/null +++ b/templates/liminalOS/configuration.nix @@ -0,0 +1,106 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). +{ + pkgs, + inputs, + ... +}: +{ + imports = [ + # Important: you should replace hardware-configuration.nix with your actual + # hardware-configuration.nix generated during NixOS installation, located + # at /etc/nixos/hardware-configuration.nix! If you don't have this file, + # re-run nixos-install to generate it. + ./hardware-configuration.nix + ]; + + networking.hostName = "liminalOS"; # Define your hostname. + + liminalOS = { + # Set this to the absolute path of the location of this configuration flake + # to enable some UX enhanacements + flakeLocation = null; + config.allowUnfree = true; + # Set your default editor to any program. + defaultEditor = pkgs.helix; + # Set to either "laptop" or "desktop" for some adjustments + formFactor = "desktop"; + # Set a wallpaper to whatever you want! You can use a local path as well. + # The colorscheme for the system is automatically generated from this + # wallpaper! + theming = { + wallpaper = pkgs.fetchurl { + url = "https://w.wallhaven.cc/full/l8/wallhaven-l8x1pr.jpg"; + hash = "sha256-Ts8igtDxLsnAnpy+tiGAXVhJWYLMHGOb2fd8lpV+UnM="; + }; + }; + system = { + # Toggle true to enable audio production software, like reaper, and yabridge + 64 bit wine for + # installing Windows-exclusive VSTs! + audio.prod.enable = false; + + networking = { + # Toggle on to allow default vite ports of 5173 and 4173 through the firewall for local testing! + firewallPresets.vite = false; + # Use cloudflare's 1.1.1.1 DNS servers + cloudflareNameservers.enable = true; + }; + graphics.nvidia.enable = true; + }; + extras.gaming = { + # Enable gaming utilities, like Heroic, Lutris, Steam + enable = true; + # Installs Roblox using Sober, as a flatpak. Note that this will enable + # the impure flatpak service that automatically updates flatpaks every + # week upon nixos-rebuild switch + roblox.enable = true; + + utilities.gamemode = { + # enable the gamemoderun binary to maximize gaming performance + enable = true; + # don't forget to update this if you change your username! + gamemodeUsers = [ "default-user" ]; + }; + }; + }; + + # Set up a user + users.users.default-user = { + isNormalUser = true; + description = "Default liminalOS user!"; + extraGroups = [ + "networkmanager" + "wheel" + ]; + shell = pkgs.fish; + }; + + home-manager.users.default-user = { + imports = [ ./home.nix ]; + }; + home-manager.extraSpecialArgs = { inherit inputs; }; + + # Set your time zone + time.timeZone = "America/Los_Angeles"; + + # Bootloader and kernel. + boot = { + loader = { + efi.canTouchEfiVariables = true; + timeout = 15; + systemd-boot = { + enable = true; + }; + }; + kernelPackages = pkgs.linuxPackages_zen; + }; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "24.05"; # Did you read the comment? +} diff --git a/templates/liminalOS/flake.nix b/templates/liminalOS/flake.nix new file mode 100644 index 0000000..1be6257 --- /dev/null +++ b/templates/liminalOS/flake.nix @@ -0,0 +1,33 @@ +{ + description = "Test standalone liminalOS system"; + + inputs = { + # Follow the nixpkgs in liminalOS, which is verified to build properly before release. + nixpkgs.follows = "liminalOS/nixpkgs"; + liminalOS.url = "github:youwen5/liminalOS/modules-refactor"; + + # Alternatively, pin your own nixpkgs and set liminalOS to follow it, as shown below. + + # nixpkgs.follows = "github:nixos/nixpkgs?ref=nixos-unstable"; + # liminalOS.url = "github:youwen5/liminalOS/modules-refactor"; + # liminalOS.inputs.nixpkgs.follows = "nixpkgs"; + + # Either way, you should ensure that liminalOS shares nixpkgs with your + # system to avoid any weird conflicts. + }; + + outputs = + inputs@{ nixpkgs, liminalOS, ... }: + { + # Execute sudo nixos-rebuild switch --flake .#liminalOS + nixosConfigurations = { + liminalOS = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + liminalOS.nixosModules.default + ./configuration.nix + ]; + }; + }; + }; +} diff --git a/templates/liminalOS/hardware-configuration.nix b/templates/liminalOS/hardware-configuration.nix new file mode 100644 index 0000000..ff26c83 --- /dev/null +++ b/templates/liminalOS/hardware-configuration.nix @@ -0,0 +1,59 @@ +# 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 = [ + "xhci_pci" + "ahci" + "nvme" + "usbhid" + "usb_storage" + "sd_mod" + ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/5a339a7f-8668-42d7-9ecc-d7a8f1d3f7b2"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-362ec972-7c5e-4c9f-ba5d-b8f2ed083509".device = + "/dev/disk/by-uuid/362ec972-7c5e-4c9f-ba5d-b8f2ed083509"; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/27EE-D950"; + fsType = "vfat"; + options = [ + "fmask=0022" + "dmask=0022" + ]; + }; + + swapDevices = [ + { device = "/dev/disk/by-uuid/670fc084-d593-44b3-aed9-78d95fec71de"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp6s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/templates/liminalOS/home.nix b/templates/liminalOS/home.nix new file mode 100644 index 0000000..994852f --- /dev/null +++ b/templates/liminalOS/home.nix @@ -0,0 +1,25 @@ +{ inputs, ... }: +{ + imports = [ + # import the liminalOS home manager module + inputs.liminalOS.homeManagerModules.default + ]; + + home = { + username = "default-user"; + homeDirectory = "/home/default-user"; + }; + + liminalOS = { + # Enable the easyeffects program to easily EQ your headphones and add + # microphone effects + utils.easyeffects.enable = true; + }; + + programs.git = { + userName = "Default User"; + userEmail = "default@localhost"; + }; + + home.stateVersion = "24.05"; +}