Skip to content

Commit

Permalink
Initial commit. Functional flake configuration prototype.
Browse files Browse the repository at this point in the history
  • Loading branch information
iivvaannxx committed Aug 24, 2023
0 parents commit 675efb2
Show file tree
Hide file tree
Showing 26 changed files with 875 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.vscode
14 changes: 14 additions & 0 deletions common/configs/networking.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ lib, pkgs, ... } @ args: let

inherit (lib) mkDefault;

in {

# Whether to use NetworkManager to obtain an IP address and other configuration for all network interfaces that are not manually configured.
# If enabled, a group 'networkmanager' will be created. Add all users that should have permission to change network settings to this group.
networking.networkmanager.enable = mkDefault true;
networking.useDHCP = mkDefault true;

# Enable the firewall by default.
networking.firewall.enable = mkDefault true;
}
58 changes: 58 additions & 0 deletions common/configs/system.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Here we define the shared system-wide configuration for each and every host.
{ lib, pkgs, ... } @ args: let

inherit (lib) mkDefault;

in {

imports = [ ./networking.nix ];

# Don't install the docs in the system. See: https://nixos.org/manual/nixos/stable/
documentation.nixos.enable = mkDefault false;
nixpkgs.config.allowUnfree = mkDefault true;

# Settings to use for the different TTY's.
console = {

earlySetup = mkDefault true;
keyMap = mkDefault "es";

packages = with pkgs; [ terminus_font ];
font = "${pkgs.terminus_font}/share/consolefonts/ter-132n.psf.gz";
};

# At least an editor to edit the configuration.
environment.systemPackages = with pkgs; [ nano ];
environment.variables = {

EDITOR = "nano";
VISUAL = "nano";
};

# Use English as language but Spanish units and currencies.
i18n.defaultLocale = mkDefault "en_US.UTF-8";
i18n.extraLocaleSettings = {

LC_NAME = mkDefault "es_ES.UTF-8";
LC_TIME = mkDefault "es_ES.UTF-8";
LC_PAPER = mkDefault "es_ES.UTF-8";
LC_ADDRESS = mkDefault "es_ES.UTF-8";
LC_NUMERIC = mkDefault "es_ES.UTF-8";
LC_MONETARY = mkDefault "es_ES.UTF-8";
LC_TELEPHONE = mkDefault "es_ES.UTF-8";
LC_MEASUREMENT = mkDefault "es_ES.UTF-8";
LC_IDENTIFICATION = mkDefault "es_ES.UTF-8";
};

# Only allow 'wheel' group members to use sudo.
security.sudo.enable = mkDefault true;
security.sudo.execWheelOnly = mkDefault true;

# Avoid problems if dual-booting with Windows.
time.hardwareClockInLocalTime = mkDefault true;
time.timeZone = mkDefault "Europe/Madrid";

# 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.
system.stateVersion = mkDefault "23.05";
}
6 changes: 6 additions & 0 deletions common/profiles/guest.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
username = "guest";
fullName = "Guest";

restrictRootAccess = true;
}
5 changes: 5 additions & 0 deletions common/profiles/ivan.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
username = "iivvaannxx";
fullName = "Ivan Porto Wigner";
email = "[email protected]";
}
66 changes: 66 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
description = "My personal NixOS Flake system configuration.";
inputs = {

nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
unstablepkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";

home-manager = {

url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { nixpkgs, unstablepkgs, home-manager, ... } @ inputs: let

# The systems where this flake was tested.
testedSystems = {

x86_64-linux = "x86_64-linux";
};

# Extend the default library with our own set of functions.
lib = (nixpkgs.lib.extend (import ./overlays/lib.nix)) // home-manager.lib;

# Creates a host using the configuration in the given path.
createHost = hostPath: system: lib.custom.mkHost {

inherit system hostPath inputs;

modules = import ./modules;
extraArgs = { };
};

in {

nixosConfigurations = {

# Home Desktop Computer.
desktop = createHost ./hosts/desktop testedSystems.x86_64-linux;
};
};
}
32 changes: 32 additions & 0 deletions hosts/desktop/configs/hardware.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ config, lib, pkgs, modulesPath, ... } @ args: let

in {

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/745067bc-0dec-42bc-b85e-10c273a7bd2d";
fsType = "ext4";
};

fileSystems."/boot" = {

device = "/dev/disk/by-uuid/FC14-3DD4";
fsType = "vfat";
};

swapDevices = [ ];

modules.hardware.nvidia.enable = true;
modules.hardware.nvidia.tryFixTearing = true;

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
6 changes: 6 additions & 0 deletions hosts/desktop/configs/networking.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ config, lib, pkgs, ... } @ args: let

in {


}
95 changes: 95 additions & 0 deletions hosts/desktop/configs/system.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{ config, lib, inputs, pkgs, upkgs, ... } @ args: let

inherit (lib.custom) importCommonConfig;

# The base configuration for every system.
commonSystemConfig = importCommonConfig "system";

in {

imports = [

./hardware.nix
./networking.nix

commonSystemConfig
];

# Boot configuration.
boot.loader.timeout = 10;
boot.loader.efi.canTouchEfiVariables = true;

# Use systemd-boot as the default bootloader. See: https://nixos.wiki/wiki/Bootloader
boot.loader.systemd-boot = {

enable = true;
editor = false;
configurationLimit = 5;
};

modules.security.root.useDoasInsteadOfSudo = true;

services.xserver.enable = true;
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
services.xserver.excludePackages = [ pkgs.xterm ];
services.xserver.desktopManager.xterm.enable = false;

# Configure keymap in X11
services.xserver = {

layout = "es";
xkbVariant = "";
};

services.gnome.core-utilities.enable = false;
environment.gnome.excludePackages = (with pkgs; [

gnome-tour
]);

services.printing.enable = false;
sound.enable = true;

hardware.pulseaudio.enable = false;

security.rtkit.enable = true;
services.pipewire = {

enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};

nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [

gnome.nautilus
gnome.seahorse
gnome.dconf-editor
gnome.gnome-tweaks
];

programs._1password-gui.enable = true;
programs._1password-gui.polkitPolicyOwners = [ "iivvaannxx" ];

nix = {

package = pkgs.nixFlakes;
extraOptions = "experimental-features = nix-command flakes";

settings = {

auto-optimise-store = true;
};

gc = {

automatic = true;
dates = "weekly";

options = "--delete-older-than-7d";
};
};
}
Loading

0 comments on commit 675efb2

Please sign in to comment.