Skip to content

Commit

Permalink
Full flake migration
Browse files Browse the repository at this point in the history
Logic mostly insipred by (stolen from) https://github.com/kenranunderscore/dotfiles

This is still missing hyprshot.
  • Loading branch information
mateusauler committed Aug 13, 2023
1 parent 9ea00fe commit 8e2ea8f
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 77 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
hardware-configuration.nix
result
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

25 changes: 0 additions & 25 deletions create-users.nix

This file was deleted.

27 changes: 27 additions & 0 deletions flake.lock

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

34 changes: 34 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
description = "My NixOS config";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

# hyprshot.url = "github:mateusauler/hyprshot-nix";
# hyprshot.inputs.nixpkgs.follows = "nixpkgs";
};

outputs = inputs@{ self, nixpkgs, ... }:
let
system = "x86_64-linux";
overlays = [
(final: prev: {
lib = prev.lib // { my = import ./lib { inherit (final) lib; }; };
})
];
pkgs = import nixpkgs {
inherit system overlays;
config.allowUnfree = true;
};
inherit (pkgs) lib;
in
{
nixosConfigurations = let
machines = lib.my.readDirNames ./hosts;
in builtins.foldl' (acc: hostname:
acc // {
${hostname} =
lib.my.mkNixosSystem { inherit hostname system inputs pkgs; };
}) { } machines;
};
}
70 changes: 29 additions & 41 deletions configuration.nix → generic/desktop.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
args@{ config, pkgs, ... }:
{ config, pkgs, custom, ... }:

{
imports = [ ./hardware-configuration.nix ./hyprland.nix ./user-specific.nix (import ./create-users.nix (args // { username = "mateus"; })) ];

boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.timeout = 0;
let username = custom.username;
in {
imports = [ ./hyprland.nix ];

networking.networkmanager.enable = true;

i18n.defaultLocale = "en_GB.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "br-abnt";
};
time.timeZone = "America/Sao_Paulo";

environment.sessionVariables = rec {
XDG_CACHE_HOME = "$HOME/.cache";
Expand Down Expand Up @@ -53,32 +46,12 @@ args@{ config, pkgs, ... }:
};
};

time.timeZone = "America/Sao_Paulo";

nixpkgs.config.allowUnfree = true;
system = {
autoUpgrade.enable = true;
copySystemConfiguration = true;
};
nix.settings = {
experimental-features = [ "nix-command" "flakes" "auto-allocate-uids" ];
auto-allocate-uids = true;
auto-optimise-store = true;
};

# ssh
services.openssh.enable = true;
security.rtkit.enable = true;
networking.firewall = {
allowedTCPPorts = [ 22 ];
allowedUDPPorts = [ 22 ];
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
programs.mtr.enable = true;
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
trusted-users = [ "root" username ];
};

programs = {
Expand All @@ -101,8 +74,7 @@ args@{ config, pkgs, ... }:
};
};

direnv.enable = true; # VSCodium Nix extension
steam.enable = true;
direnv.enable = true; # VSCodium Nix extension
};

fonts = {
Expand All @@ -123,17 +95,16 @@ args@{ config, pkgs, ... }:
btop
du-dust
easyeffects
efibootmgr
exa
ferdium
firefox
firejail
git
heroic
home-manager
htop-vim
keepassxc
librewolf
lutris
megasync
meld
mpv
Expand All @@ -143,10 +114,8 @@ args@{ config, pkgs, ... }:
onlyoffice-bin
pcmanfm
pfetch
prismlauncher
qbittorrent
qogir-icon-theme
refind
ripgrep
spotify
syncthing-tray
Expand All @@ -159,6 +128,25 @@ args@{ config, pkgs, ... }:
zathura
];

system.stateVersion = "22.11";
}
programs.fish.enable = true;

users.defaultUserShell = pkgs.fish;

services.syncthing = {
user = "${username}";
dataDir = "/home/${username}/Sync";
configDir = "/home/${username}/.config/syncthing";
};

users.users = {
${username} = {
isNormalUser = true;
group = "users";
extraGroups = [ "wheel" "input" "networkmanager" ];
initialPassword = "a";
createHome = true;
home = "/home/${username}";
};
root.initialPassword = "a";
};
}
14 changes: 14 additions & 0 deletions generic/efi.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ config, pkgs, ... }:

{
boot.loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
timeout = 0;
};

environment.systemPackages = with pkgs; [
efibootmgr
refind
];
}
2 changes: 1 addition & 1 deletion hyprland.nix → generic/hyprland.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
copyq
hyprpicker

(builtins.getFlake "path:/etc/nixos/hyprshot").packages.x86_64-linux.default
# (builtins.getFlake "path:/etc/nixos/hyprshot").packages.x86_64-linux.default
];
}
18 changes: 18 additions & 0 deletions generic/openssh.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ config, pkgs, ... }:

{
# ssh
services.openssh.enable = true;
security.rtkit.enable = true;
networking.firewall = {
allowedTCPPorts = [ 22 ];
allowedUDPPorts = [ 22 ];
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
programs.mtr.enable = true;
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
}
24 changes: 24 additions & 0 deletions hosts/GLaDOS/configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ config, pkgs, custom, ... }:

let username = custom.username;
in {
imports = [ ./hardware-configuration.nix ../../generic/efi.nix ../../generic/desktop.nix ../../generic/openssh.nix ];

networking.hostName = "GLaDOS";

i18n.defaultLocale = "en_GB.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "br-abnt";
};

programs.steam.enable = true;

environment.systemPackages = with pkgs; [
lutris
prismlauncher
];

system.stateVersion = "22.11";
}

3 changes: 3 additions & 0 deletions hosts/GLaDOS/custom.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
username = "mateus";
}
42 changes: 42 additions & 0 deletions hosts/GLaDOS/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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" "nvme" "usbhid" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];

fileSystems."/" =
{ device = "/dev/disk/by-label/nix_root";
fsType = "ext4";
};

fileSystems."/home" =
{ device = "/dev/disk/by-label/nix_home";
fsType = "ext4";
};

fileSystems."/boot" =
{ device = "/dev/disk/by-label/nix_efi";
fsType = "vfat";
};

swapDevices = [ ];

# 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.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;

nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
1 change: 0 additions & 1 deletion hyprshot
Submodule hyprshot deleted from 69bf25
30 changes: 30 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ lib, ... }:

{
readDirNames = path:
builtins.attrNames
(lib.filterAttrs (_: type: type == "directory") (builtins.readDir path));

mkNixosSystem = { hostname, system, inputs, pkgs }:
let
inherit (inputs) home-manager nixpkgs;
dir = ../hosts + "/${hostname}";
custom = (import (dir + /custom.nix)) // { inherit hostname; };
username = custom.username;
specialArgs = { inherit inputs custom; };
in nixpkgs.lib.nixosSystem {
inherit system pkgs specialArgs;
modules = [
(dir + /configuration.nix)
# home-manager.nixosModules.home-manager
# {
# home-manager = {
# users.${username} = import (dir + /home.nix);
# useGlobalPkgs = true;
# useUserPackages = false;
# extraSpecialArgs = specialArgs;
# };
# }
];
};
}
5 changes: 0 additions & 5 deletions user-specific.nix

This file was deleted.

0 comments on commit 8e2ea8f

Please sign in to comment.