treewide: sorting

This commit is contained in:
Guanran Wang 2023-11-17 13:38:25 +08:00
parent 3c2192c0f7
commit f98ee5581a
Signed by: nyancat
SSH key fingerprint: SHA256:8oWGKciPALWut/6WA27oFKofX+6Wtc0gQnsefXLQx/8
103 changed files with 202 additions and 219 deletions

View file

@ -6,7 +6,7 @@ It just works™
- Flakes: Yes - Flakes: Yes
- Home Manager: Yes - Home Manager: Yes
### Machine-specific (81fw-nixos) ### Machine-specific (Aristotle)
- File system: Btrfs - File system: Btrfs
- System encryption: Yes (LUKS) - System encryption: Yes (LUKS)
@ -18,34 +18,21 @@ It just works™
## Structure ## Structure
``` ```
 .  .
├──  darwin # System configuration │ ### System configuration
├──  darwin
├──  nixos ├──  nixos
│ ├──  flake-modules
│ ├──  hardware
│ ├──  modules
│ └──  profiles
├──  flakes # Import-able Flakes │ ### User configuration
│ ├──  darwin │ # Adds user account, home-manager stuff, etc.
│ └──  nixos │ # Do whatever you want here.
├──  machines # Hardware configuration
│ ├──  darwin
│ └──  nixos
│ ├──  81fw-lenovo-legion-y7000 ### Model
│ │ ├──  hardware.nix #### Model-specific hardware configuration
│ │ └──  machine-1 #### Machine-specific hardware configuration
│ │
│ └───  hardware ### Reusable hardware configuration
│ ├──  cpu
│ ├──  gpu
│ └──  ...
├──  users ├──  users
│ └──  guanranwang ## Your user │ ├──  guanranwang
│ │ │ ├──  foo
│ ├──  darwin ### (User-specific) System configuration │ └──  bar
│ ├──  nixos
│ │
│ ├──  home-manager ### (User-specific) Home Manager configuration
│ │
│ └──  secrets ### User's secrets managed through sops-nix
├──  flake.nix ├──  flake.nix
├──  flake.lock ├──  flake.lock
@ -61,7 +48,7 @@ It just works™
`$ git clone https://github.com/Guanran928/flake.git` `$ git clone https://github.com/Guanran928/flake.git`
2. 2.
Add your device's hardware configuration in `./machines` and `./flake.nix` Add your device's hardware configuration in `./ (nixos/darwin) /hardware` and `./flake.nix`
3. 3.
Install NixOS Install NixOS

View file

@ -0,0 +1,5 @@
{...}: {
imports = [
./networking
];
}

View file

@ -0,0 +1,29 @@
{
lib,
config,
...
}: {
options.myFlake.darwin.networking.dns = lib.mkOption {
type = lib.types.enum ["google" "alidns"];
default = "google";
example = "alidns";
description = "Select your DNS provider";
};
config.networking.dns = lib.mkMerge [
(lib.mkIf (config.myFlake.darwin.networking.dns == "google") [
### Google DNS
"8.8.8.8"
"8.8.4.4"
"2001:4860:4860::8888"
"2001:4860:4860::8844"
])
(lib.mkIf (config.myFlake.darwin.networking.dns == "alidns") [
### AliDNS
"223.5.5.5"
"223.6.6.6"
"2400:3200::1"
"2400:3200:baba::1"
])
];
}

View file

@ -1,17 +0,0 @@
{...}: {
# please configure `networking.knownNetworkServices` in ../hosts/your-machine.nix
networking.dns = [
"223.5.5.5"
"223.6.6.6"
"2400:3200::1"
"2400:3200:baba::1"
#"223.5.5.5#dns.alidns.com"
#"223.6.6.6#dns.alidns.com"
#"2400:3200::1#dns.alidns.com"
#"2400:3200:baba::1#dns.alidns.com"
#"8.8.8.8"
#"8.8.4.4"
#"2001:4860:4860::8888"
#"2001:4860:4860::8844"
];
}

View file

@ -1,8 +0,0 @@
{...}: {
imports = [
../networking
../nix
../packages
../system
];
}

View file

@ -0,0 +1,9 @@
{...}: {
imports = [
../../modules
./nix
./packages
./system
];
}

View file

@ -188,64 +188,43 @@
specialArgs = {inherit inputs;}; specialArgs = {inherit inputs;};
modules = [ modules = [
# OS # OS
./nixos/presets/desktop.nix ./nixos/profiles/desktop
./nixos/presets/core/zram-generator.nix ./nixos/profiles/core/addtional/zram-generator.nix
./nixos/presets/desktop/gaming.nix ./nixos/profiles/desktop/addtional/gaming.nix
./nixos/presets/desktop/virtualbox.nix ./nixos/profiles/desktop/addtional/virtualbox.nix
./nixos/presets/desktop/wayland.nix ./nixos/profiles/desktop/addtional/wayland.nix
./nixos/presets/desktop/virt-manager.nix ./nixos/profiles/desktop/addtional/virt-manager.nix
# User # User
./users/guanranwang/nixos/presets/desktop.nix ./users/guanranwang/nixos/profiles/desktop
./users/guanranwang/nixos/presets/core/clash-meta-client.nix ./users/guanranwang/nixos/profiles/core/addtional/clash-meta-client.nix
./users/guanranwang/nixos/presets/desktop/gaming.nix ./users/guanranwang/nixos/profiles/desktop/addtional/gaming.nix
./users/guanranwang/nixos/presets/desktop/torrenting.nix ./users/guanranwang/nixos/profiles/desktop/addtional/torrenting.nix
# Hardware # Hardware
./machines/nixos/81fw-lenovo-legion-y7000 ./nixos/hardware/81fw-lenovo-legion-y7000/Aristotle
./machines/nixos/81fw-lenovo-legion-y7000/Aristotle
{ {networking.hostName = "Aristotle";}
networking.hostName = "Aristotle"; # Hostname
time.timeZone = "Asia/Shanghai"; # Timezone
### Options
myFlake.nixos.boot.noLoaderMenu = true;
myFlake.nixos.networking.dns = "alidns";
}
]; ];
}; };
}; };
### nix-darwin ### Darwin
darwinConfigurations = { darwinConfigurations = {
"Plato" = nix-darwin.lib.darwinSystem { "Plato" = nix-darwin.lib.darwinSystem {
system = "x86_64-darwin"; system = "x86_64-darwin";
specialArgs = {inherit inputs;}; specialArgs = {inherit inputs;};
modules = [ modules = [
./darwin/presets/desktop.nix ./darwin/profiles/desktop
./users/guanranwang/darwin/presets/desktop.nix
./users/guanranwang/darwin/presets/core/proxy.nix
./machines/darwin/imac-2017
{ ./users/guanranwang/darwin/profiles/desktop
networking.hostName = "Plato"; ./users/guanranwang/darwin/profiles/core/addtional/networking/clash-meta-client.nix
time.timeZone = "Asia/Shanghai";
} ./darwin/hardware/imac-2017
{networking.hostName = "Plato";}
]; ];
}; };
}; };
### Standalone Home-Manager
#homeConfigurations = {
# "guanranwang@81fw-nixos" = home-manager.lib.homeManagerConfiguration {
# pkgs = nixpkgs.legacyPackages.x86_64-linux;
# extraSpecialArgs = {inherit inputs;};
# modules = [
# sops-nix.homeManagerModules.sops
# hyprland.homeManagerModules.default
# ];
# };
#};
}; };
} }

View file

@ -1,10 +0,0 @@
{...}: {
imports = [
../../../../flakes/nixos/lanzaboote.nix
../../../../flakes/nixos/impermanence.nix
../../../../flakes/nixos/disko.nix
];
_module.args.disks = ["/dev/nvme0n1"]; # Disko
boot.initrd.systemd.enable = true; # LUKS TPM unlocking
}

View file

@ -0,0 +1,11 @@
{...}: {
imports = [
../default.nix
../../../../nixos/flake-modules/lanzaboote.nix
../../../../nixos/flake-modules/impermanence.nix
../../../../nixos/flake-modules/disko.nix
];
_module.args.disks = ["/dev/nvme0n1"]; # Disko
boot.initrd.systemd.enable = true; # LUKS TPM unlocking
}

View file

@ -1,6 +1,5 @@
{...}: { {...}: {
imports = [ imports = [
./boot.nix ./boot.nix
./sysctl.nix
]; ];
} }

View file

@ -0,0 +1,6 @@
{...}: {
imports = [
./boot
./networking
];
}

View file

@ -1,13 +1,11 @@
{config, ...}: {config, ...}: {
# Imported by default, check out ./desktop.nix or ./server.nix # Imported by default, check out ./desktop.nix or ./server.nix
{
imports = [ imports = [
../boot ../../modules # idk where should i import it
../networking
../nix ./nix
../packages ./packages
../power-management ./sysctl.nix
#../specialisation # dont actually use this
]; ];
users.mutableUsers = false; users.mutableUsers = false;

View file

@ -1,7 +1,9 @@
{pkgs, ...}: { {pkgs, ...}: {
imports = [ imports = [
./core.nix ../core
../packages/graphical
./power-management
./graphical
]; ];
boot.kernelPackages = pkgs.linuxPackages_zen; boot.kernelPackages = pkgs.linuxPackages_zen;

View file

@ -3,6 +3,6 @@
{ {
imports = [ imports = [
(modulesPath + "/profiles/minimal.nix") (modulesPath + "/profiles/minimal.nix")
./core.nix ../core
]; ];
} }

View file

@ -1,21 +0,0 @@
{...}: {
specialisation = {
bspwm.configuration = {
system.nixos.tags = ["bspwm"];
services.xserver = {
displayManager.startx.enable = true;
windowManager.bspwm.enable = true;
};
};
plasma.configuration = {
system.nixos.tags = ["plasma"];
services.xserver = {
desktopManager.plasma5.enable = true;
displayManager.sddm = {
enable = true;
settings.General.DisplayServer = "wayland";
};
};
};
};
}

View file

@ -1,21 +0,0 @@
{pkgs, ...}: {
users = {
knownUsers = ["guanranwang"];
users."guanranwang" = {
createHome = true;
description = "Guanran Wang";
home = "/Users/guanranwang";
shell = pkgs.fish;
uid = 501;
};
};
imports = [
../../../../flakes/darwin/home-manager.nix
];
home-manager.users.guanranwang.imports = [
../..
../../profiles/command-line/darwin
];
}

View file

@ -1,19 +0,0 @@
{...}: {
imports = [
./core.nix
];
### home-manager
home-manager.users.guanranwang.imports = [
./core.nix
../../modules/terms/alacritty.nix
../../modules/shell/fish.nix
../../modules/shell/bash.nix
../../modules/editor/helix.nix
../../modules/editor/neovim.nix
../../modules/editor/vscode.nix
../home.nix
]; # NOTE: using flakes
}

View file

@ -0,0 +1,31 @@
{
pkgs,
lib,
...
}: {
users = {
knownUsers = ["guanranwang"];
users."guanranwang" = {
createHome = true;
description = "Guanran Wang";
home = "/Users/guanranwang";
shell = pkgs.fish;
uid = 501;
};
};
### Options
myFlake.darwin.networking.dns = lib.mkDefault "alidns";
time.timeZone = lib.mkDefault "Asia/Shanghai";
### Flakes
imports = [
../../../../../darwin/flake-modules/home-manager.nix
];
### home-manager
home-manager.users.guanranwang.imports = map (n: ../../../home-manager/${n}) [
"default.nix"
"profiles/command-line/darwin"
];
}

View file

@ -1,5 +1,5 @@
{...}: { {...}: {
home-manager.users.guanranwang.imports = [ home-manager.users.guanranwang.imports = [
../../../home-manager/profiles/gaming/nixos ../../../../../home-manager/profiles/gaming/darwin
]; ];
} }

View file

@ -0,0 +1,17 @@
{...}: {
imports = [
../core
];
### home-manager
home-manager.users.guanranwang.imports = map (n: ../../../home-manager/${n}) [
"modules/terms/alacritty.nix"
"modules/shell/fish.nix"
"modules/shell/bash.nix"
"modules/editor/helix.nix"
"modules/editor/neovim.nix"
"modules/editor/vscode.nix"
"profiles/graphical-stuff/darwin"
];
}

View file

@ -6,17 +6,11 @@
}; };
home.packages = with pkgs; [ home.packages = with pkgs; [
### Sans ### Inter
inter inter
### Monospace ### JetBrains Mono Nerd Font
jetbrains-mono (nerdfonts.override {fonts = ["JetBrainsMono"];})
(nerdfonts.override {
fonts = [
"JetBrainsMono"
"NerdFontsSymbolsOnly"
];
})
### Adobe Source Han ### Adobe Source Han
source-han-sans source-han-sans

View file

@ -7,7 +7,7 @@
etcDirectory = "clash-meta"; etcDirectory = "clash-meta";
in { in {
imports = [ imports = [
../../../../../flakes/nixos/sops-nix.nix ../../../../../../nixos/flake-modules/sops-nix.nix
]; ];
### sops-nix ### sops-nix

View file

@ -7,7 +7,7 @@
port = 43956; port = 43956;
in { in {
imports = [ imports = [
../../../../../flakes/nixos/sops-nix.nix ../../../../../../nixos/flake-modules/sops-nix.nix
]; ];
### Firewall ### Firewall

View file

@ -7,7 +7,7 @@
port = "33829"; port = "33829";
in { in {
imports = [ imports = [
../../../../../flakes/nixos/sops-nix.nix ../../../../../../nixos/flake-modules/sops-nix.nix
]; ];
### Firewall ### Firewall

View file

@ -1,6 +1,7 @@
{ {
pkgs, pkgs,
config, config,
lib,
... ...
}: { }: {
users.users."guanranwang" = { users.users."guanranwang" = {
@ -19,20 +20,24 @@
packages = []; packages = [];
}; };
# for default shell ### for default shell
programs.fish.enable = true; programs.fish.enable = true;
### Options
myFlake.nixos.networking.dns = lib.mkDefault "alidns";
time.timeZone = lib.mkDefault "Asia/Shanghai";
### Flakes
imports = [ imports = [
### Flakes ../../../../../nixos/flake-modules/sops-nix.nix
../../../../flakes/nixos/sops-nix.nix ../../../../../nixos/flake-modules/hosts.nix
../../../../flakes/nixos/hosts.nix
]; ];
### sops-nix ### sops-nix
nix.extraOptions = "!include ${config.sops.secrets.nix-access-tokens.path}"; nix.extraOptions = "!include ${config.sops.secrets.nix-access-tokens.path}";
users.groups."nix-access-tokens" = {}; users.groups."nix-access-tokens" = {};
sops = { sops = {
defaultSopsFile = ../../secrets/secrets.yaml; defaultSopsFile = ../../../secrets/secrets.yaml;
age.sshKeyPaths = ["/nix/persist/system/etc/ssh/ssh_host_ed25519_key"]; age.sshKeyPaths = ["/nix/persist/system/etc/ssh/ssh_host_ed25519_key"];
gnupg.sshKeyPaths = []; gnupg.sshKeyPaths = [];
secrets = { secrets = {
@ -46,8 +51,8 @@
}; };
### home-manager ### home-manager
home-manager.users.guanranwang.imports = [ home-manager.users.guanranwang.imports = map (n: ../../../home-manager/${n}) [
../../home-manager "default.nix"
../../home-manager/profiles/command-line/nixos "profiles/command-line/nixos"
]; ];
} }

Some files were not shown because too many files have changed in this diff Show more