restructure

- users/rin/default.nix -> users/rin.nix
- users/rin/home.nix +-> users/rin.nix
- users/rin/*.nix -> modules/user/*.nix
- users/rin/scripts/ -> scripts/
- hosts/winter/default.nix -> hosts/winter.nix
- hosts/winter/*.nix -> modules/system/*.nix

- modules are dynamically imported as sets for system and user
This commit is contained in:
LavaDesu 2021-07-15 15:09:38 +07:00
parent 84f08a3a1c
commit c86be50084
Signed by: cilly
GPG key ID: 6500251E087653C9
30 changed files with 178 additions and 157 deletions

View file

@ -17,10 +17,32 @@
outputs = inputs: with inputs;
let
lib = nixpkgs.lib;
getPaths = root: builtins.map
(path: root + ("/" + path)) # Prepends root path
(builtins.attrNames (builtins.readDir root)); # Reads root path
modules =
let
getName = path: lib.removeSuffix ".nix" ( # Strip extension
lib.last ( # Gets the last part (filename)
lib.splitString "/" ( # Splits the path into components
builtins.toString path # Converts the path into a string
)
)
);
genModulePaths = basePath: builtins.listToAttrs (
builtins.map (path: {
name = getName path;
value = path;
}) (getPaths basePath)
);
in {
user = genModulePaths ./modules/user;
system = genModulePaths ./modules/system;
};
customPackages = pkgs:
let
callPackage = pkgs.callPackage;
@ -32,7 +54,7 @@
overlays = (builtins.map
(path: import path) # Imports path
(builtins.filter
(path: nixpkgs.lib.hasSuffix ".nix" path) # Checks file extension
(path: lib.hasSuffix ".nix" path) # Checks file extension
(getPaths ./overlays)
)
) ++ [(self: super: customPackages super)]
@ -55,23 +77,23 @@
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs;
inherit inputs modules;
enableGUI = true;
};
};
};
in
{
nixosConfigurations."winter" = nixpkgs.lib.nixosSystem {
nixosConfigurations."winter" = lib.nixosSystem {
system = "x86_64-linux";
modules = [
base
home-manager.nixosModules.home-manager
./hosts/winter
./hosts/winter.nix
secrets.nixosModules.winter
];
specialArgs = {
inherit inputs;
inherit inputs modules;
enableGUI = true;
};
};

View file

@ -1,4 +1,4 @@
{ config, overlays, pkgs, ... }: {
{ config, modules, overlays, pkgs, ... }: {
networking.hostName = "winter";
system.stateVersion = "20.09";
@ -12,17 +12,17 @@
environment.pathsToLink = [ "/share/zsh" ];
users.mutableUsers = false;
imports = [
./audio.nix
./gui.nix
./hardware-configuration.nix
./kernel.nix
./networking.nix
./packages.nix
./security.nix
./snapper.nix
imports = with modules.system; [
audio
gui
hardware-configuration
kernel
networking
packages
security
snapper
../../users/rin
../users/rin.nix
];
nix = rec {
package = pkgs.nixUnstable;

View file

@ -1,7 +1,7 @@
{ config, ... }: {
services.polybar = {
enable = true;
script = builtins.readFile ./scripts/polybar.sh;
script = builtins.readFile ../../scripts/polybar.sh;
settings = {
"bar/top" = {
monitor = "eDP-1";

View file

@ -6,7 +6,7 @@
scriptPath = ".config/xorg/xsession";
};
xdg.configFile."xorg/xinitrc".source = ./scripts/xinitrc;
xdg.configFile."xorg/xinitrc".source = ../../scripts/xinitrc;
xdg.configFile."xorg/wallpaper.png".source = ../../res/wallpaper.png;
xresources = {
path = "${config.xdg.configHome}/xorg/xresources";

138
users/rin.nix Normal file
View file

@ -0,0 +1,138 @@
{ config, lib, modules, pkgs, ... }: {
users.users.rin = {
isNormalUser = true;
extraGroups = [ "audio" "video" "wheel" ];
shell = pkgs.zsh;
uid = 1001;
};
home-manager.users.rin = { config, enableGUI, lib, pkgs, ... }: {
home = {
username = "rin";
homeDirectory = "/home/rin";
stateVersion = "21.05";
packages = with pkgs; [
ffmpeg
gnupg
neofetch
nodejs-16_x
pamixer
rnix-lsp
transcrypt
unrar
wine-osu
(winetricks.override { wine = wine-osu; })
youtube-dl
nodePackages_latest.pnpm
] ++ lib.optionals enableGUI [
brave
discord-canary
element-desktop
feh
gnome.file-roller
gimp
kotatogram-desktop
lxappearance
maim
pavucontrol
tor-browser-bundle-bin
transmission-remote-gtk
xclip
xorg.xgamma
];
sessionVariables = {
PATH = builtins.concatStringsSep ":" [
"${config.home.homeDirectory}/.local/bin"
"${config.xdg.dataHome}/npm/bin"
"$PATH"
];
XAUTHORITY = "$XDG_RUNTIME_DIR/Xauthority";
EDITOR = "nvim";
_JAVA_OPTIONS = "-Djava.util.prefs.userRoot=${config.xdg.configHome}/java";
CARGO_HOME = "${config.xdg.dataHome}/cargo";
DIRENV_LOG_FORMAT = "";
GNUPGHOME = "${config.xdg.dataHome}/gnupg";
GTK2_RC_FILES = "${config.xdg.configHome}/gtk-2.0/gtkrc";
LESSHISTFILE = "-";
NODE_REPL_HISTORY="${config.xdg.dataHome}/nodejs/repl_history";
NPM_CONFIG_USERCONFIG = "${config.xdg.configHome}/npm/npmrc";
PUB_CACHE = "${config.xdg.cacheHome}/dart";
WGETRC = "${config.xdg.configHome}/wgetrc";
XINITRC = "${config.xdg.configHome}/xorg/xinitrc";
WINEPREFIX = "${config.xdg.dataHome}/wine64";
WINEARCH = "win64";
};
};
imports = with modules.user; [
neovim
npm
zsh
] ++ lib.optionals enableGUI [
theming
xdg
kitty
mpv
rofi
dunst
picom
polybar
xorg
sxhkd
bspwm
];
programs = {
feh.enable = enableGUI;
direnv = {
enable = true;
nix-direnv = {
enable = true;
enableFlakes = true;
};
};
git = {
enable = true;
userName = "LavaDesu";
userEmail = "me@lava.moe";
signing = {
key = "059F098EBF0E9A13E10A46BF6500251E087653C9";
signByDefault = true;
};
extraConfig = {
core.abbrev = 11;
};
};
gpg = {
enable = true;
homedir = "${config.xdg.dataHome}/gnupg";
};
};
services = {
# TODO: borked
clipmenu.enable = false;
gpg-agent = {
enable = true;
pinentryFlavor = if enableGUI then "gnome3" else "tty";
};
};
home.file.".local/bin/ipc-bridge.exe".source = builtins.fetchurl {
url = "https://github.com/0e4ef622/wine-discord-ipc-bridge/releases/download/v0.0.1/winediscordipcbridge.exe";
sha256 = "1swn9spxpq6blm74kjmfz4ipq6a8qjzccvb2msb25pf5b1z7jnns";
};
home.file.".local/bin/osu" = {
executable = true;
source = ../scripts/osu;
};
};
}

View file

@ -1,9 +0,0 @@
{ config, pkgs, ... }: {
users.users.rin = {
isNormalUser = true;
extraGroups = [ "audio" "video" "wheel" ];
shell = pkgs.zsh;
uid = 1001;
};
home-manager.users.rin = import ./home.nix;
}

View file

@ -1,130 +0,0 @@
{ config, enableGUI, lib, pkgs, ... }: {
home = {
username = "rin";
homeDirectory = "/home/rin";
stateVersion = "21.05";
packages = with pkgs; [
ffmpeg
gnupg
neofetch
nodejs-16_x
pamixer
rnix-lsp
transcrypt
unrar
wine-osu
(winetricks.override { wine = wine-osu; })
youtube-dl
nodePackages_latest.pnpm
] ++ lib.optionals enableGUI [
brave
discord-canary
element-desktop
feh
gnome.file-roller
gimp
kotatogram-desktop
lxappearance
maim
pavucontrol
tor-browser-bundle-bin
transmission-remote-gtk
xclip
xorg.xgamma
];
sessionVariables = {
PATH = builtins.concatStringsSep ":" [
"${config.home.homeDirectory}/.local/bin"
"${config.xdg.dataHome}/npm/bin"
"$PATH"
];
XAUTHORITY = "$XDG_RUNTIME_DIR/Xauthority";
EDITOR = "nvim";
_JAVA_OPTIONS = "-Djava.util.prefs.userRoot=${config.xdg.configHome}/java";
CARGO_HOME = "${config.xdg.dataHome}/cargo";
DIRENV_LOG_FORMAT = "";
GNUPGHOME = "${config.xdg.dataHome}/gnupg";
GTK2_RC_FILES = "${config.xdg.configHome}/gtk-2.0/gtkrc";
LESSHISTFILE = "-";
NODE_REPL_HISTORY="${config.xdg.dataHome}/nodejs/repl_history";
NPM_CONFIG_USERCONFIG = "${config.xdg.configHome}/npm/npmrc";
PUB_CACHE = "${config.xdg.cacheHome}/dart";
WGETRC = "${config.xdg.configHome}/wgetrc";
XINITRC = "${config.xdg.configHome}/xorg/xinitrc";
WINEPREFIX = "${config.xdg.dataHome}/wine64";
WINEARCH = "win64";
};
};
imports = [
./neovim.nix
./npm.nix
./zsh.nix
] ++ lib.optionals enableGUI [
./theming.nix
./xdg.nix
./kitty.nix
./mpv.nix
./rofi.nix
./dunst.nix
./picom.nix
./polybar.nix
./xorg.nix
./sxhkd.nix
./bspwm.nix
];
programs = {
feh.enable = enableGUI;
direnv = {
enable = true;
nix-direnv = {
enable = true;
enableFlakes = true;
};
};
git = {
enable = true;
userName = "LavaDesu";
userEmail = "me@lava.moe";
signing = {
key = "059F098EBF0E9A13E10A46BF6500251E087653C9";
signByDefault = true;
};
extraConfig = {
core.abbrev = 11;
};
};
gpg = {
enable = true;
homedir = "${config.xdg.dataHome}/gnupg";
};
};
services = {
# TODO: borked
clipmenu.enable = false;
gpg-agent = {
enable = true;
pinentryFlavor = if enableGUI then "gnome3" else "tty";
};
};
home.file.".local/bin/ipc-bridge.exe".source = builtins.fetchurl {
url = "https://github.com/0e4ef622/wine-discord-ipc-bridge/releases/download/v0.0.1/winediscordipcbridge.exe";
sha256 = "1swn9spxpq6blm74kjmfz4ipq6a8qjzccvb2msb25pf5b1z7jnns";
};
home.file.".local/bin/osu" = {
executable = true;
source = ./scripts/osu;
};
}