I'm Sorry
This commit is contained in:
commit
8c7bdaf9f7
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
networking.nix
|
||||
result
|
60
flake.lock
Normal file
60
flake.lock
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"nodes": {
|
||||
"home-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1639891275,
|
||||
"narHash": "sha256-2IMLVTtOHV9kBsirGPRpo8NE48Mjq20iXN7l7uy0YjE=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "3db603677509eb0b8c396a3234b1d4b70d023894",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1640012693,
|
||||
"narHash": "sha256-D07/CBpeqsbXKb96NQliVqgB3ytLL3XfBGBrm/eaUxU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "7dcb25726b3a5ed3896fe38362f631ca5bed4a6e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1639966735,
|
||||
"narHash": "sha256-FmVGFiyqE+pjQUTCTY0H75hqrnBnbEf3VVRB4dsd4KI=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d87b72206aadebe6722944f541f55d33fd7046fb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"home-manager": "home-manager",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
10
flake.nix
Normal file
10
flake.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
description = "NixOS configuration";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
home-manager.url = "github:nix-community/home-manager";
|
||||
};
|
||||
|
||||
outputs = { ... }@inputs: import ./outputs.nix inputs;
|
||||
}
|
1
home/base/example.nix
Normal file
1
home/base/example.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ ... }: { }
|
18
home/default.nix
Normal file
18
home/default.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ lib, tree, ... }: with lib; let
|
||||
wrapImports = imports: mapAttrs
|
||||
(_: paths: { config, ... }: {
|
||||
config.home-manager.users.chaoticryptidz = {
|
||||
imports = singleton paths;
|
||||
};
|
||||
})
|
||||
imports;
|
||||
dirImports = wrapImports tree.prev;
|
||||
in
|
||||
dirImports // {
|
||||
base = {
|
||||
imports = [
|
||||
dirImports.base
|
||||
tree.prev.nixos
|
||||
];
|
||||
};
|
||||
}
|
13
home/gui/gtk.nix
Normal file
13
home/gui/gtk.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ config, pkgs, ... }: {
|
||||
gtk = {
|
||||
enable = true;
|
||||
iconTheme = {
|
||||
name = "Papirus-Dark";
|
||||
package = pkgs.papirus-icon-theme;
|
||||
};
|
||||
theme = {
|
||||
name = "Adementary-dark";
|
||||
package = pkgs.adementary-theme;
|
||||
};
|
||||
};
|
||||
}
|
6
home/network_manager/nm.nix
Normal file
6
home/network_manager/nm.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{ config, ... }: {
|
||||
xsession.preferStatusNotifierItems = true;
|
||||
services = {
|
||||
network-manager-applet.enable = true;
|
||||
};
|
||||
}
|
6
home/nixos.nix
Normal file
6
home/nixos.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{ config, ... }: {
|
||||
users.users.chaoticryptidz = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" ];
|
||||
};
|
||||
}
|
19
hosts/default.nix
Normal file
19
hosts/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ home-manager, nixpkgs, tree, ... }@inputs: let
|
||||
defaultModules = [
|
||||
home-manager.nixosModules.home-manager
|
||||
tree.impure.profiles.base
|
||||
];
|
||||
defaultSpecialArgs = {
|
||||
tree = tree.impure;
|
||||
pureTree = tree.pure;
|
||||
inherit inputs;
|
||||
};
|
||||
in {
|
||||
nixos = nixpkgs.lib.nixosSystem {
|
||||
specialArgs = defaultSpecialArgs;
|
||||
system = "x86_64-linux";
|
||||
modules = defaultModules ++ [
|
||||
./nixos.nix
|
||||
];
|
||||
};
|
||||
}
|
44
hosts/nixos.nix
Normal file
44
hosts/nixos.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{ tree, config, pkgs, lib, ... }:
|
||||
|
||||
{
|
||||
imports = with tree; [
|
||||
profiles.dev
|
||||
profiles.gui
|
||||
profiles.x11
|
||||
profiles.xfce
|
||||
profiles.laptop
|
||||
profiles.pulse
|
||||
profiles.network_manager
|
||||
home.gui
|
||||
home.network_manager
|
||||
];
|
||||
|
||||
boot = {
|
||||
loader = {
|
||||
systemd-boot.enable = true;
|
||||
efi.canTouchEfiVariables = true;
|
||||
};
|
||||
initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
|
||||
kernelModules = [ "kvm-intel" ];
|
||||
};
|
||||
|
||||
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
hardware.enableRedistributableFirmware = true;
|
||||
|
||||
networking.hostName = "nixos";
|
||||
|
||||
fileSystems = {
|
||||
"/" = {
|
||||
device = "/dev/disk/by-uuid/491ec94c-5e6a-4d23-a2a6-bcf4971a6e7b";
|
||||
fsType = "ext4";
|
||||
};
|
||||
"/boot" = {
|
||||
device = "/dev/disk/by-uuid/61F3-FD84";
|
||||
fsType = "vfat";
|
||||
};
|
||||
};
|
||||
|
||||
system.stateVersion = "21.11";
|
||||
}
|
||||
|
18
outputs.nix
Normal file
18
outputs.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ nixpkgs, home-manager, ... }@inputs: let
|
||||
mkTree = import ./tree.nix { inherit (nixpkgs) lib; };
|
||||
tree = mkTree {
|
||||
inherit inputs;
|
||||
folder = ./.;
|
||||
config = {
|
||||
"profiles/*".functor.enable = true;
|
||||
"home".evaluateDefault = true;
|
||||
"home/*".functor.enable = true;
|
||||
};
|
||||
};
|
||||
in {
|
||||
legacyPackages.tree = tree;
|
||||
nixosConfigurations = import ./hosts {
|
||||
nixosSystem = nixpkgs.lib.nixosSystem;
|
||||
inherit nixpkgs home-manager tree;
|
||||
};
|
||||
}
|
11
overlay/comic-code/default.nix
Normal file
11
overlay/comic-code/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ fetchzip }: fetchzip {
|
||||
name="comic-code-1.0";
|
||||
|
||||
url = "https://cdn.discordapp.com/attachments/780878889924165652/919700644347142214/COCOD.ZIP";
|
||||
sha256 = "sha256-MzEkMAopjpQBk24nRVDAtGNeF6f61XGww4rya2cU8TU=";
|
||||
|
||||
postFetch = ''
|
||||
mkdir -p $out/share/fonts
|
||||
unzip -j $downloadedFile \*.otf -d $out/share/fonts/truetype
|
||||
'';
|
||||
}
|
3
overlay/default.nix
Normal file
3
overlay/default.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
final: prev: {
|
||||
comic-code = final.callPackage ./comic-code { };
|
||||
}
|
7
profiles/base/access.nix
Normal file
7
profiles/base/access.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ tree, config, lib, ... }: {
|
||||
security.sudo.wheelNeedsPassword = lib.mkForce false;
|
||||
|
||||
imports = with tree; [
|
||||
home.base
|
||||
];
|
||||
}
|
3
profiles/base/hardware.nix
Normal file
3
profiles/base/hardware.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{ ... }: {
|
||||
hardware.enableRedistributableFirmware = true;
|
||||
}
|
17
profiles/base/home.nix
Normal file
17
profiles/base/home.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ inputs, tree, config, lib, ... }: with lib; {
|
||||
options.home-manager.users = mkOption {
|
||||
type = types.attrsOf (types.submoduleWith {
|
||||
modules = [ ];
|
||||
specialArgs = {
|
||||
inherit inputs tree;
|
||||
nixos = config;
|
||||
};
|
||||
});
|
||||
};
|
||||
config = {
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
};
|
||||
};
|
||||
}
|
7
profiles/base/locale.nix
Normal file
7
profiles/base/locale.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ config, ... }: {
|
||||
i18n.defaultLocale = "en_GB.UTF-8";
|
||||
console = {
|
||||
font = "Lat2-Terminus16";
|
||||
keyMap = "uk";
|
||||
};
|
||||
}
|
19
profiles/base/nix.nix
Normal file
19
profiles/base/nix.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ inputs, config, lib, ... }: {
|
||||
nix = {
|
||||
nixPath = [
|
||||
"nixpkgs=${inputs.nixpkgs}"
|
||||
];
|
||||
extraOptions = lib.optionalString (lib.versionAtLeast config.nix.package.version "2.4") ''
|
||||
experimental-features = nix-command flakes
|
||||
'';
|
||||
trustedUsers = [ "root" "@wheel" ];
|
||||
};
|
||||
nixpkgs = {
|
||||
config = {
|
||||
allowUnfree = true;
|
||||
};
|
||||
overlays = [
|
||||
(import ../../overlay)
|
||||
];
|
||||
};
|
||||
}
|
3
profiles/base/programs.nix
Normal file
3
profiles/base/programs.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{ config, ... }: {
|
||||
programs.mtr.enable = true;
|
||||
}
|
1
profiles/dev/default.nix
Normal file
1
profiles/dev/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ ... }: { }
|
18
profiles/gui/default.nix
Normal file
18
profiles/gui/default.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ config, pkgs, ... }: {
|
||||
fonts.fonts = with pkgs; [
|
||||
iosevka
|
||||
comic-code
|
||||
];
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
git
|
||||
nano
|
||||
curl
|
||||
wget
|
||||
vscode
|
||||
tdesktop
|
||||
vivaldi
|
||||
vivaldi-ffmpeg-codecs
|
||||
vivaldi-widevine
|
||||
];
|
||||
}
|
3
profiles/laptop/default.nix
Normal file
3
profiles/laptop/default.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{ config, ... }: {
|
||||
services.xserver.libinput.enable = true;
|
||||
}
|
10
profiles/network_manager/nm.nix
Normal file
10
profiles/network_manager/nm.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ config, lib, ... }: {
|
||||
networking = {
|
||||
networkmanager = {
|
||||
enable = true;
|
||||
connectionConfig = {
|
||||
"ipv6.ip6-privacy" = lib.mkForce 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
4
profiles/pulse/default.nix
Normal file
4
profiles/pulse/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{ config, ... }: {
|
||||
sound.enable = true;
|
||||
hardware.pulseaudio.enable = true;
|
||||
}
|
4
profiles/x11/default.nix
Normal file
4
profiles/x11/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{ config, ... }: {
|
||||
services.xserver.enable = true;
|
||||
services.xserver.layout = "gb";
|
||||
}
|
6
profiles/xfce/default.nix
Normal file
6
profiles/xfce/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{ config, ... }: {
|
||||
services.xserver = {
|
||||
desktopManager.xfce.enable = true;
|
||||
displayManager.defaultSession = "xfce";
|
||||
};
|
||||
}
|
10
rebuild.sh
Executable file
10
rebuild.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
set -x
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
FIRST_ARG="${1:-switch}"
|
||||
|
||||
shift
|
||||
|
||||
nixos-rebuild --flake "${SCRIPT_DIR}#$(hostname)" ${FIRST_ARG} $@
|
121
tree.nix
Normal file
121
tree.nix
Normal file
|
@ -0,0 +1,121 @@
|
|||
{ lib }: { config, folder, inputs, ... }@args: with lib; let
|
||||
pureTreeGrab = { base, path }: let
|
||||
realPath = toString path;
|
||||
dirContents = builtins.readDir path;
|
||||
isDirectory = entry: dirContents."${entry}" == "directory";
|
||||
isHidden = entry: hasPrefix "." entry;
|
||||
isDir = entry: _: (isDirectory entry) && !(isHidden entry);
|
||||
directories = filterAttrs isDir dirContents;
|
||||
isNixFile = entry: _: let
|
||||
result = builtins.match "(.*)\\.nix" entry;
|
||||
in result != null && builtins.length result > 0;
|
||||
nixFiles = filterAttrs isNixFile dirContents;
|
||||
getPath = entry: "${realPath}/${entry}";
|
||||
getPaths = entries: mapAttrs' (n: v:
|
||||
nameValuePair (removeSuffix ".nix" n) (getPath n)
|
||||
) entries;
|
||||
nixFilePaths = getPaths nixFiles;
|
||||
dirPaths = getPaths directories;
|
||||
recursedPaths = mapAttrs (_: fullPath: pureTreeGrab {
|
||||
inherit base;
|
||||
path = fullPath;
|
||||
}) dirPaths;
|
||||
contents = recursedPaths // nixFilePaths;
|
||||
in contents;
|
||||
configTreeStruct = { config, ... }: {
|
||||
options.treeConfig = mkOption {
|
||||
type = with types; attrsOf (submodule ({ name, options, config, ... }: {
|
||||
options = {
|
||||
evaluateDefault = mkOption {
|
||||
type = types.bool;
|
||||
description = "Replace the contents of this branch or leaf with those provided by the evaluation of default.nix.";
|
||||
default = false;
|
||||
};
|
||||
aliasDefault = mkOption {
|
||||
type = types.bool;
|
||||
description = "Replace the contents of this branch or leaf with the default.nix.";
|
||||
default = false;
|
||||
};
|
||||
excludes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = "Exclude files or folders from the recurser.";
|
||||
default = [];
|
||||
};
|
||||
functor = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
description = "Provide a functor for the path provided";
|
||||
default = false;
|
||||
};
|
||||
external = mkOption {
|
||||
type = types.listOf types.unspecified;
|
||||
description = "Add external imports into the functor.";
|
||||
default = [];
|
||||
};
|
||||
excludes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = "Exclude files or folders from the functor.";
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
};
|
||||
}));
|
||||
};
|
||||
config.treeConfig = {
|
||||
"*" = {};
|
||||
};
|
||||
};
|
||||
configTree.treeConfig = config;
|
||||
configTreeModule = (evalModules {
|
||||
modules = [
|
||||
configTreeStruct
|
||||
configTree
|
||||
];
|
||||
}).config.treeConfig;
|
||||
mapAttrsRecursive = f: set: let
|
||||
recurse = path: set: let
|
||||
g = name: value: if isAttrs value
|
||||
then f (path ++ [name]) (recurse (path ++ [name]) value)
|
||||
else f (path ++ [name]) value;
|
||||
in mapAttrs g set;
|
||||
in recurse [] set;
|
||||
getPathString = path: concatStringsSep "/" path;
|
||||
getConfig = path: default: configTreeModule.${getPathString path} or default;
|
||||
revtail = path: sublist 0 (length path - 1) path;
|
||||
getConfigRecursive = path: let
|
||||
parentPath = revtail path;
|
||||
in getConfig (path ++ singleton "*") (getConfigRecursive parentPath);
|
||||
processLeaves = tree: config: mapAttrsRecursive (path: value: let
|
||||
pathString = getPathString path;
|
||||
leafConfig = getConfig path (getConfigRecursive (revtail path));
|
||||
processConfig = path: value: let
|
||||
processFunctor = prev: prev // {
|
||||
__functor = self: { ... }: {
|
||||
imports = attrValues (removeAttrs prev leafConfig.functor.excludes) ++ leafConfig.functor.external;
|
||||
};
|
||||
};
|
||||
processAliasDefault = prev: prev.default;
|
||||
processDefault = prev: import prev.default (args // {
|
||||
inherit lib;
|
||||
tree = {
|
||||
prev = removeAttrs prev (singleton "default");
|
||||
pure = pureTree;
|
||||
impure = impureTree;
|
||||
};
|
||||
});
|
||||
processExcludes = prev: removeAttrs prev leafConfig.excludes;
|
||||
processes = optionals (isAttrs value) (
|
||||
optional (leafConfig.excludes != []) processExcludes
|
||||
++ optional leafConfig.evaluateDefault processDefault
|
||||
++ optional leafConfig.aliasDefault processAliasDefault
|
||||
++ optional leafConfig.functor.enable processFunctor
|
||||
);
|
||||
in pipe value processes;
|
||||
in processConfig path value) tree;
|
||||
pureTree = pureTreeGrab { base = folder; path = folder; };
|
||||
impureTree = processLeaves pureTree configTreeModule;
|
||||
in {
|
||||
config = configTreeModule;
|
||||
pure = pureTree;
|
||||
impure = impureTree;
|
||||
}
|
Loading…
Reference in a new issue