diff --git a/README.md b/README.md deleted file mode 100644 index 3cc6c8c..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# saturnOS-template - -a template which will be used to configure and create a saturnOS system \ No newline at end of file diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..9d9ce0c --- /dev/null +++ b/configuration.nix @@ -0,0 +1,5 @@ +# symlinkg this file to your /etc/nixos/ and make sure the directory is correct ! +{...}: +{ + imports = [ ./hardware-configuration.nix ./saturnOS ]; +} diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..7427cae --- /dev/null +++ b/default.nix @@ -0,0 +1,56 @@ +# welcome to saturnOS config, run nixos-help if you need it . +{ config, pkgs, lib, ... }: +{ + imports = [ + ./modules + ./system + ]; + + # nix options + nix.settings = { + experimental-features = "nix-command flakes"; + auto-optimise-store = true; + }; + + # enable gnome + services.xserver.enable = true; + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + # enable dconf configuration for gnome and other supported applications + programs.dconf.enable = true; + + # configure pipewire + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + }; + + # install packages + # `nix search` to add more + nixpkgs.config.allowUnfree = true; + environment.systemPackages = with pkgs; [ + ]; + + # set fish as default shell for all users + users.defaultUserShell = pkgs.fish; + + # suid wrapper ( for things which need privelidged acccess, or additional configuration ) + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + pinentryFlavor = "gnome3"; + }; + programs.fish.enable = true; + + # enable configure services + services.printing.enable = true; # printing + services.openssh.enable = true; # remote shell + services.flatpak.enable = true; #flatpak lol +} diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..47bd7b9 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + imports = [ + ./saturnConfig.nix + ./machineInfo.nix + ]; +} diff --git a/modules/machineInfo.nix b/modules/machineInfo.nix new file mode 100644 index 0000000..a30f2a1 --- /dev/null +++ b/modules/machineInfo.nix @@ -0,0 +1,119 @@ +{ config, pkgs, lib, ... }@nixpkgs: with lib; { + options.environment.machineInfo = mkOption { + description = lib.mdDoc '' + Machine metadata, including stylized hostname, computer icon, etc. + + This module controls the options written to `/etc/machine-info`. For more + information, see [the freedesktop documentation][1]. + + [1]: https://www.freedesktop.org/software/systemd/man/machine-info.html + ''; + default = {}; + type = types.submodule { options = { + + prettyHostname = mkOption { + description = lib.mdDoc '' + A pretty, human-readable hostname for this machine, potentially including + spaces, unicode, and emoji. If unset, this falls back to the network hostname + set in `networking.hostName`. + ''; + type = with types; nullOr str; + default = null; + defaultText = literalExpression "null"; + example = literalExpression "\"Jade's Laptop 💎\""; + }; + + iconName = mkOption { + description = lib.mdDoc '' + An XDG icon which should be associated with this machine. Some common choices + include: `"computer"`, `"phone"`, but a complete list of icons can be found in + the [XDG Icon Naming Spec][1]. + + If left unset, applications will typically default to `"computer"`. + + [1]: https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html + ''; + type = with types; nullOr str; + default = null; + defaultText = literalExpression "null"; + example = literalExpression "\"computer\""; + }; + + chassis = mkOption { + description = lib.mdDoc '' + The type of chassis this machine resides within. This is typically detected + automatically, but can be manually overridden here. + ''; + type = with types; nullOr (enum [ + "desktop" + "laptop" + "convertible" + "server" + "tablet" + "handset" + "watch" + "embedded" + "vm" + "container" + ]); + default = null; + defaultText = literalExpression "null"; + example = literalExpression "\"server\""; + }; + + deployment = mkOption { + description = lib.mdDoc '' + If this machine is part of a deployment environment / pipeline, this option can + be used to specify what environment/pipeline stage it manages. + + Typically, but not necessarily, set to something like `"development"`, + `"integration"`, `"staging"`, or `"production"`. + ''; + type = with types; nullOr str; + default = null; + defaultText = literalExpression "null"; + example = literalExpression "\"production\""; + }; + + location = mkOption { + description = lib.mdDoc '' + A human-readable short description of the location of this machine. + + This can be set to whatever has the most meaning for you, for example "Living + Room", "Left Rack, 2nd Shelf", or "Parishville, NY". + ''; + type = with types; nullOr str; + default = null; + defaultText = literalExpression "null"; + example = literalExpression "\"Bedroom\""; + }; + + extraOptions = mkOption { + description = lib.mdDoc '' + Extra variables to put in `/etc/machine-info` + ''; + type = with types; attrsOf str; + default = {}; + defaultText = literalExpression "{ }"; + example = literalExpression "{ HARDWARE_VENDOR = \"Intel Corp.\" }"; + }; + + };}; + }; + + config.environment.etc.machine-info = + with config.environment.machineInfo; + let + rawShellVars = { + PRETTY_HOSTNAME = prettyHostname; + ICON_NAME = iconName; + CHASSIS = chassis; + DEPLOYMENT = deployment; + LOCATION = location; + } // extraOptions; + nonNullShellVars = attrsets.filterAttrs (k: v: v != null) rawShellVars; + in rec { + text = strings.toShellVars nonNullShellVars; + enable = builtins.stringLength text > 0; + }; +} \ No newline at end of file diff --git a/modules/saturnConfig.nix b/modules/saturnConfig.nix new file mode 100644 index 0000000..9767b36 --- /dev/null +++ b/modules/saturnConfig.nix @@ -0,0 +1,25 @@ +{ config, lib, ... }: with lib; +{ + options.saturn = { + user = mkOption { + type = types.str; + default = "saturn"; + description = mdDoc "The name of the user of the system."; + }; + hostname = mkOption { + type = types.strMatching + "[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?"; + default = "saturnOS-device"; + description = mdDoc "The network hostname of the system, which must only contain letters, + numbers, and dashes, and cannot start or end with a dash."; + }; + prettyHostname = mkOption { + type = types.str; + default = "🪐 saturnOS"; + description = mdDoc "The pretty hostname is used for things like bluetooth pairing, + device sharing, and is fully unicode."; + }; + }; + config.networking.hostName = config.saturn.hostname; + config.environment.machineInfo.prettyHostname = config.saturn.prettyHostname; +} diff --git a/system/custom.nix b/system/custom.nix new file mode 100644 index 0000000..4280f4e --- /dev/null +++ b/system/custom.nix @@ -0,0 +1,2 @@ +# this is for options not managed bysaturnConfig, added by the user +# again this is an example template not meant to be used diff --git a/system/default.nix b/system/default.nix new file mode 100644 index 0000000..3e86766 --- /dev/null +++ b/system/default.nix @@ -0,0 +1,45 @@ +#this is a template, but would be auto-generated by saturnConfig, when the system is first created and on later modification to the system options +# it is not reccomended to use this file, as it should be generated by the script only +{ config, pkgs, lib, ... }: +{ + # importing custom user config + imports = [ ./custom.nix ]; + + # settings hostname + saturn.hostname = "saturnOS"; + saturn.prettyHostname = "🪐 saturnOS"; + + # efi bootloader + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.efi.efiSysMountPoint = "/boot/efi"; + boot.initrd.systemd.enable = true; + boot.plymouth.enable = true; + boot.kernelParams = ["quiet"]; + + # configure networking + networking.networkmanager.enable = true; + + # configure locale + time.timeZone = "Etc/UTC"; + i18n.defaultLocale = "en_CA.UTF-8"; + + # configure x11 keymap + services.xserver = { + layout = "us"; + xkbVariant = ""; + }; + + # add and configure users + users.users.saturn = { + initialPassword = ""; + isNormalUser = true; + description = "Saturn User"; + extraGroups = [ "networkmanager" "wheel" ]; + }; + + # import home-manager config from home.nix ( kept for legacy reasons ) + # home-manager.users.${sysConf.user} = import "${userDir}/home.nix" sysConf; + + system.stateVersion = "23.05"; +}