nix/flake.nix

352 lines
11 KiB
Nix
Raw Normal View History

# This is a configuration entry-point called "Flake".
# Here you define your inputs (dependencies) and outputs (hosts).
{
# Those are external dependencies.
inputs = {
# Core system.
# Homepage: https://github.com/NixOS/nixpkgs
# Manual: https://nixos.org/manual/nixos/stable
# Search: https://search.nixos.org/packages and https://search.nixos.org/options
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# This thing manages user's /home directroies. Because NixOS only manages system itself.
# Homepage: https://github.com/nix-community/home-manager
# Manual: https://nix-community.github.io/home-manager
# Search: https://home-manager-options.extranix.com
home-manager = {
url = "github:nix-community/home-manager";
# This means that home-manager and our Flake both depend on the same nixpkgs version.
inputs.nixpkgs.follows = "nixpkgs";
};
# This allows automatic styling based on active Wallpaper.
# Homepage: https://github.com/danth/stylix
# Manual: https://danth.github.io/stylix
stylix.url = "github:danth/stylix";
# Nix on Android (inside Termux). It has no NixOS modules, but still allows the use of Nixpkgs arm packages with Home-Manager configurations.
# Homepage: https://github.com/nix-community/nix-on-droid
# Manual: https://github.com/nix-community/nix-on-droid/blob/master/README.md
nix-on-droid = {
url = "github:t184256/nix-on-droid/release-23.05";
2024-03-04 23:11:23 +03:00
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
# Those are Nvim plugins. I do not use package managers like Packer or Lazy, instead I use Nix to download them and later configure in [Neovim module](module/common/Nvim.nix).
nvimAlign = {
2024-04-03 07:34:36 +03:00
url = "github:echasnovski/mini.align";
flake = false;
};
nvimAutoclose = {
2024-04-03 07:34:36 +03:00
url = "github:m4xshen/autoclose.nvim";
flake = false;
};
nvimBufferline = {
2024-04-03 07:34:36 +03:00
url = "github:akinsho/bufferline.nvim";
flake = false;
};
nvimCloseBuffers = {
2024-04-03 07:34:36 +03:00
url = "github:kazhala/close-buffers.nvim";
flake = false;
};
2024-04-04 04:02:29 +03:00
nvimColorizer = {
url = "github:brenoprata10/nvim-highlight-colors";
flake = false;
};
nvimDevicons = {
2024-04-03 07:34:36 +03:00
url = "github:nvim-tree/nvim-web-devicons";
flake = false;
};
nvimGitsigns = {
2024-04-03 07:34:36 +03:00
url = "github:lewis6991/gitsigns.nvim";
flake = false;
};
2024-03-05 22:25:23 +03:00
nvimGruvboxMaterial = {
2024-04-03 07:34:36 +03:00
url = "github:sainnhe/gruvbox-material";
flake = false;
};
nvimIndentoMatic = {
2024-04-03 07:34:36 +03:00
url = "github:Darazaki/indent-o-matic";
flake = false;
};
nvimLspconfig = {
2024-04-03 07:34:36 +03:00
url = "github:neovim/nvim-lspconfig";
flake = false;
};
nvimOllama = {
2024-04-03 07:34:36 +03:00
url = "github:nomnivore/ollama.nvim";
flake = false;
};
nvimPlenary = {
2024-04-03 07:34:36 +03:00
url = "github:nvim-lua/plenary.nvim";
flake = false;
};
nvimSingleComment = {
2024-04-03 07:34:36 +03:00
url = "github:LucasTavaresA/singlecomment.nvim";
flake = false;
};
nvimTelescope = {
2024-04-03 07:34:36 +03:00
url = "github:nvim-telescope/telescope.nvim";
flake = false;
};
nvimTodo = {
2024-04-03 07:34:36 +03:00
url = "github:folke/todo-comments.nvim";
flake = false;
};
nvimTokyonight = {
2024-04-03 07:34:36 +03:00
url = "github:folke/tokyonight.nvim";
flake = false;
};
nvimTree = {
2024-04-03 07:34:36 +03:00
url = "github:nvim-tree/nvim-tree.lua";
flake = false;
};
nvimTreesitter = {
2024-04-03 07:34:36 +03:00
url = "github:nvim-treesitter/nvim-treesitter";
flake = false;
};
nvimTrouble = {
2024-04-03 07:34:36 +03:00
url = "github:folke/trouble.nvim";
flake = false;
};
nvimWhichKey = {
2024-04-03 07:34:36 +03:00
url = "github:folke/which-key.nvim";
flake = false;
};
};
# Those are outputs (hosts, configurations) that can be produced by this whole config.
# Here you see a set of inputs we defined above, like nixpkgs, home-manager and so on.
# `...` at the end of a set means "ignore other arguments provided to this function".
# @inputs means aliasing all the inputs to the `inputs` name, so we can pass them all at once later.
2024-04-03 00:23:03 +03:00
outputs = { self, nixpkgs, nix-on-droid, home-manager, stylix, ... } @inputs: {
# Constant values.
2024-04-15 00:41:40 +03:00
const = {
2024-03-04 23:11:23 +03:00
droidStateVersion = "22.11";
2024-03-15 16:37:56 +03:00
stateVersion = "23.11";
2024-03-26 06:36:00 +03:00
timeZone = "Europe/Moscow";
url = "https://git.voronind.com/voronind/nixos.git";
};
# Common modules used across all the hosts.
nixosModules.common = let
# This function allows me to get the list of all the files from the directories I need.
# It differs from the util.ls function because it also filters out all the directories.
2024-04-28 21:24:49 +03:00
lsFiles = path: map (f: "${path}/${f}") (
2024-04-15 11:28:52 +03:00
builtins.filter (i: builtins.readFileType "${path}/${i}" == "regular") (
builtins.attrNames (builtins.readDir path)
)
);
in {
# Here I import everything from those directories.
2024-04-28 21:24:49 +03:00
imports = (lsFiles ./module/common) ++ (lsFiles ./overlay) ++ [ ./user/Root.nix ];
};
# Function to create a host. It does basic setup, like adding common modules.
2024-04-06 03:03:58 +03:00
mkHost = { system, hostname, modules } @args: nixpkgs.lib.nixosSystem {
# `Inherit` is just an alias for `system = system;`, which means that
# keep the `system` argument as a property in a resulting set.
inherit system;
# List of modules to use by defualt for all the hosts.
modules = [
# There I put host-specific configurations.
./host/${hostname}
# Make a device hostname match the one from this config.
{ networking.hostName = hostname; }
# Specify current release version.
2024-04-15 00:41:40 +03:00
{ system.stateVersion = self.const.stateVersion; }
# Add common modules.
inputs.self.nixosModules.common
# Add Home Manager module.
home-manager.nixosModules.home-manager
# Add Stylix module.
2024-04-03 00:23:03 +03:00
stylix.nixosModules.stylix
]
# Also add host-specific modules from mkHost args.
++ modules;
# SpecialArgs allows you to pass objects down to other NixOS modules.
2024-04-06 03:03:58 +03:00
specialArgs = let
pkgs = nixpkgs.legacyPackages.${system}.pkgs;
config = self.nixosConfigurations.${hostname}.config;
in {
const = self.const; # Constant values.
flake = self; # This Flake itself.
inputs = inputs; # Our dependencies.
key = import ./part/Key.nix {}; # Keyboard keys config.
secret = import ./part/Secret.nix {}; # Secrets (public keys).
setting = import ./part/Setting.nix {}; # My own global settings.
style = import ./part/Style.nix { config = config; }; # Style abstraction.
util = import ./part/Util.nix { pkgs = pkgs; }; # Util functions.
wallpaper = import ./part/Wallpaper.nix { pkgs = pkgs; }; # Wallpaper.
2024-03-31 22:34:21 +03:00
};
};
# Bellow is the list of all the hosts I currently use.
# They call the `mkHost` function that I defined above
# with their specific parameters.
# You might be interested in `live` and `nixOnDroidConfiguration`
# for Live ISO and Android configurations respectively.
2024-04-10 14:52:37 +03:00
nixosConfigurations.basic = self.mkHost {
hostname = "basic"; # Hostname to use.
system = "x86_64-linux"; # System architecture.
# Host-specific modules.
2024-04-10 14:52:37 +03:00
modules = [
# Force LTS kernel.
2024-04-10 14:52:37 +03:00
({ pkgs, ... }: { boot.kernelPackages = nixpkgs.lib.mkForce pkgs.linuxPackages; })
];
};
nixosConfigurations.dasha = self.mkHost {
hostname = "dasha";
system = "x86_64-linux";
modules = [
./module/AmdGpu.nix
./module/CapsToggle.nix
./module/Gnome.nix
./module/IntelCpu.nix
./module/PowersaveIntel.nix
./module/Print.nix
./module/RemoteBuild.nix
./module/StrongSwan.nix
./module/Tablet.nix
./user/Dasha.nix
];
};
nixosConfigurations.desktop = self.mkHost {
hostname = "desktop";
system = "x86_64-linux";
modules = [
2024-03-20 22:54:40 +03:00
./module/AmdCompute.nix
./module/AmdCpu.nix
./module/AmdGpu.nix
# ./module/Ollama.nix # ISSUE: Currently broken.
./module/PowersaveAmd.nix
./module/Print.nix
2024-03-09 20:19:48 +03:00
./module/RemoteBuild.nix
2024-03-28 08:57:07 +03:00
./module/Sway.nix
./module/VirtManager.nix
./user/Voronind.nix
];
};
nixosConfigurations.fsight = self.mkHost {
hostname = "fsight";
system = "x86_64-linux";
modules = [
./module/Docker.nix
];
};
nixosConfigurations.home = self.mkHost {
hostname = "home";
system = "x86_64-linux";
modules = [
./module/AmdCpu.nix
./module/AmdGpu.nix
./module/Docker.nix
./module/Ftpd.nix
2024-03-09 20:19:48 +03:00
./module/RemoteBuilder.nix
2024-03-28 08:45:55 +03:00
./module/Sway.nix
./user/Voronind.nix
];
};
nixosConfigurations.laptop = self.mkHost {
hostname = "laptop";
system = "x86_64-linux";
modules = [
./module/AmdCpu.nix
2024-03-04 21:19:30 +03:00
./module/AmdGpu.nix
./module/CapsToggle.nix
./module/Gnome.nix
./module/PowersaveAmd.nix
./module/Print.nix
./module/RemoteBuild.nix
./module/StrongSwan.nix
./module/Tablet.nix
./user/Dasha.nix
./user/Voronind.nix
];
};
# Live ISO configuration.
nixosConfigurations.live = self.mkHost {
hostname = "live";
system = "x86_64-linux";
modules = [
# Those are basic modules for Live ISO image.
# You can discover other possible base images here:
# https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/installer/cd-dvd
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
"${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix"
# This is required for Live ISO in my case because I use NetworkManager,
# but base Live images require this.
{ networking.wireless.enable = nixpkgs.lib.mkForce false; }
# Override my settings to allow SSH logins using root password.
2024-03-10 08:04:23 +03:00
{ services.openssh.settings.PasswordAuthentication = nixpkgs.lib.mkForce true; }
{ services.openssh.settings.PermitRootLogin = nixpkgs.lib.mkForce "yes"; }
# Disable auto-updates as they are not possible for Live ISO.
{ systemd.services.autoupdate.enable = nixpkgs.lib.mkForce false; }
# Base Live images also require the LTS kernel.
({ pkgs, ... }: { boot.kernelPackages = nixpkgs.lib.mkForce pkgs.linuxPackages; })
];
};
nixosConfigurations.work = self.mkHost {
hostname = "work";
system = "x86_64-linux";
modules = [
./module/IntelCpu.nix
./module/PowerlimitThinkpad.nix
./module/PowersaveIntel.nix
./module/Print.nix
./module/RemoteBuild.nix
2024-03-28 04:27:37 +03:00
./module/Sway.nix
./user/Voronind.nix
];
};
# Android.
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
modules = [
# Android release version.
2024-04-15 00:41:40 +03:00
{ system.stateVersion = inputs.self.const.droidStateVersion; }
# I put all my Android configuration there.
./module/android
];
2024-04-06 03:03:58 +03:00
# SpecialArgs allows you to pass objects down to other configuration.
2024-04-06 03:03:58 +03:00
extraSpecialArgs = let
# We want arm64 packages for Android.
2024-04-06 03:03:58 +03:00
pkgs = nixpkgs.legacyPackages."aarch64-linux".pkgs;
in {
const = self.const; # Constant values.
flake = self; # This Flake itself.
inputs = inputs; # Our dependencies.
key = import ./part/Key.nix {}; # Keyboard keys config.
secret = import ./part/Secret.nix {}; # Secrets (public keys).
setting = import ./part/Setting.nix {}; # My own global settings.
style = import ./part/Style.nix { config = import ./part/style/Gruvbox.nix {}; }; # Style abstraction. Stylix is not available for Android so I provide static Gruvbox style.
util = import ./part/Util.nix { pkgs = pkgs; }; # Util functions.
2024-03-31 22:34:21 +03:00
};
};
};
}
# That's it!