2021-11-25 11:55:30 +00:00
|
|
|
{
|
2022-11-25 06:35:11 +00:00
|
|
|
description = "foo-dogsquared's abomination of a NixOS configuration";
|
2022-02-04 12:48:02 +00:00
|
|
|
|
|
|
|
nixConfig = {
|
2022-03-28 00:15:40 +00:00
|
|
|
extra-substituters =
|
2023-07-30 06:17:04 +00:00
|
|
|
"https://nix-community.cachix.org https://foo-dogsquared.cachix.org";
|
2022-03-28 00:15:40 +00:00
|
|
|
extra-trusted-public-keys =
|
2023-07-30 06:17:04 +00:00
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= foo-dogsquared.cachix.org-1:/2fmqn/gLGvCs5EDeQmqwtus02TUmGy0ZlAEXqRE70E=";
|
2022-02-04 12:48:02 +00:00
|
|
|
};
|
|
|
|
|
2021-11-25 11:55:30 +00:00
|
|
|
inputs = {
|
2022-08-27 05:30:04 +00:00
|
|
|
# I know NixOS can be stable but we're going cutting edge, baybee! While
|
|
|
|
# `nixpkgs-unstable` branch could be faster delivering updates, it is
|
|
|
|
# looser when it comes to stability for the entirety of this configuration.
|
2023-11-08 12:34:06 +00:00
|
|
|
nixpkgs.follows = "nixos-unstable";
|
2023-06-22 03:01:41 +00:00
|
|
|
|
|
|
|
# Here are the nixpkgs variants used for creating the system configuration
|
|
|
|
# in `mkHost`.
|
2023-12-04 10:40:30 +00:00
|
|
|
nixos-stable.url = "github:NixOS/nixpkgs/nixos-23.11";
|
2023-06-22 03:01:41 +00:00
|
|
|
nixos-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
nixos-unstable-small.url = "github:NixOS/nixpkgs/nixos-unstable-small";
|
2023-12-04 10:29:37 +00:00
|
|
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2021-12-06 10:12:00 +00:00
|
|
|
|
2022-11-25 06:35:11 +00:00
|
|
|
# We're using these libraries for other functions.
|
2021-12-18 09:41:45 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
|
2021-12-11 05:37:27 +00:00
|
|
|
# Managing home configurations.
|
2023-12-04 10:51:41 +00:00
|
|
|
home-manager.follows = "home-manager-unstable";
|
|
|
|
home-manager-stable.url = "github:nix-community/home-manager/release-23.11";
|
|
|
|
home-manager-unstable.url = "github:nix-community/home-manager";
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2022-01-02 00:48:15 +00:00
|
|
|
# This is what AUR strives to be.
|
|
|
|
nur.url = "github:nix-community/NUR";
|
|
|
|
|
2022-02-04 15:36:22 +00:00
|
|
|
# Generate your NixOS systems to various formats!
|
|
|
|
nixos-generators.url = "github:nix-community/nixos-generators";
|
|
|
|
nixos-generators.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2021-12-11 05:37:27 +00:00
|
|
|
# Managing your secrets.
|
2022-07-17 01:36:29 +00:00
|
|
|
sops-nix.url = "github:Mic92/sops-nix";
|
|
|
|
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
|
2021-12-06 07:33:03 +00:00
|
|
|
|
2023-11-24 02:11:26 +00:00
|
|
|
# NixOS in Windows.
|
|
|
|
nixos-wsl.url = "github:nix-community/NixOS-WSL";
|
|
|
|
nixos-wsl.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2021-12-18 09:41:45 +00:00
|
|
|
# Easy access to development environments.
|
|
|
|
devshell.url = "github:numtide/devshell";
|
2022-07-14 01:10:34 +00:00
|
|
|
devshell.inputs.nixpkgs.follows = "nixpkgs";
|
2021-12-18 09:41:45 +00:00
|
|
|
|
2022-11-25 06:35:11 +00:00
|
|
|
# We're getting more unstable there should be a black hole at my home right
|
|
|
|
# now. Also, we're seem to be collecting text editors like it is Pokemon.
|
2021-12-06 07:33:03 +00:00
|
|
|
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
|
2023-04-22 06:09:29 +00:00
|
|
|
neovim-nightly-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
2022-07-09 21:40:56 +00:00
|
|
|
|
2022-01-02 00:40:01 +00:00
|
|
|
emacs-overlay.url = "github:nix-community/emacs-overlay";
|
2022-07-09 21:40:56 +00:00
|
|
|
emacs-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
2022-01-02 00:40:01 +00:00
|
|
|
|
2022-08-04 13:32:15 +00:00
|
|
|
helix-editor.url = "github:helix-editor/helix";
|
|
|
|
helix-editor.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2022-02-27 02:07:18 +00:00
|
|
|
# Generating an entire flavored themes with Nix?
|
|
|
|
nix-colors.url = "github:misterio77/nix-colors";
|
2022-11-13 05:49:54 +00:00
|
|
|
|
2023-06-30 04:55:40 +00:00
|
|
|
# Removing the manual partitioning part with a little boogie.
|
|
|
|
disko.url = "github:nix-community/disko";
|
|
|
|
disko.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2022-11-13 05:49:54 +00:00
|
|
|
# Deploying stuff with Nix. This is becoming a monorepo for everything I
|
|
|
|
# need and I'm liking it.
|
|
|
|
deploy.url = "github:serokell/deploy-rs";
|
|
|
|
deploy.inputs.nixpkgs.follows = "nixpkgs";
|
2023-07-06 03:05:15 +00:00
|
|
|
|
2023-11-04 06:58:02 +00:00
|
|
|
# Add a bunch of pre-compiled indices since mine are always crashing.
|
|
|
|
nix-index-database.url = "github:nix-community/nix-index-database";
|
|
|
|
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
|
2021-11-25 11:55:30 +00:00
|
|
|
};
|
|
|
|
|
2022-01-07 03:09:32 +00:00
|
|
|
outputs = inputs@{ self, nixpkgs, ... }:
|
2021-11-25 11:55:30 +00:00
|
|
|
let
|
2023-06-20 06:48:38 +00:00
|
|
|
# A set of images with their metadata that is usually built for usual
|
|
|
|
# purposes. The format used here is whatever formats nixos-generators
|
|
|
|
# support.
|
2023-12-23 12:26:40 +00:00
|
|
|
images = import ./setups/nixos.nix { lib = lib'; inherit inputs; };
|
2023-06-20 06:48:38 +00:00
|
|
|
|
2023-06-23 07:43:26 +00:00
|
|
|
# A set of users with their metadata to be deployed with home-manager.
|
2023-12-23 12:26:40 +00:00
|
|
|
users = import ./setups/home-manager.nix { lib = lib'; inherit inputs; };
|
2023-06-23 07:43:26 +00:00
|
|
|
|
2023-06-20 06:48:38 +00:00
|
|
|
# A set of image-related utilities for the flake outputs.
|
2023-12-23 03:03:17 +00:00
|
|
|
inherit (import ./lib/extras/images.nix { inherit inputs; lib = lib'; }) mkHost mkHome mkImage listImagesWithSystems;
|
2023-06-20 06:48:38 +00:00
|
|
|
|
2022-01-02 14:30:00 +00:00
|
|
|
# The order here is important(?).
|
2021-12-06 07:33:03 +00:00
|
|
|
overlays = [
|
2023-09-28 10:33:00 +00:00
|
|
|
# My own set of Firefox addons. They're not included in the packages
|
|
|
|
# output since they'll be a pain in the ass to set up for others when
|
|
|
|
# this is also included. If I set this up to be easily included in
|
|
|
|
# others' flake, it'll have a potential conflict for NUR users
|
|
|
|
# (including myself) that also relies on rycee's NUR instance. Overall,
|
|
|
|
# it's a pain to setup so I'm not including this.
|
2023-07-06 03:05:15 +00:00
|
|
|
(final: prev: {
|
2023-12-15 12:41:27 +00:00
|
|
|
inherit (final.nur.repos.rycee.firefox-addons) buildFirefoxXpiAddon;
|
2023-07-14 14:13:09 +00:00
|
|
|
firefox-addons = final.callPackage ./pkgs/firefox-addons { };
|
2023-07-06 03:05:15 +00:00
|
|
|
})
|
|
|
|
|
2021-12-06 07:33:03 +00:00
|
|
|
# Neovim nightly!
|
2023-06-08 04:14:28 +00:00
|
|
|
inputs.neovim-nightly-overlay.overlays.default
|
2021-12-26 09:33:00 +00:00
|
|
|
|
2022-01-02 00:40:01 +00:00
|
|
|
# Emacs unstable version!
|
2023-06-08 04:14:28 +00:00
|
|
|
inputs.emacs-overlay.overlays.default
|
2022-01-02 00:40:01 +00:00
|
|
|
|
2022-01-02 00:48:15 +00:00
|
|
|
# Access to NUR.
|
|
|
|
inputs.nur.overlay
|
2023-09-25 10:14:56 +00:00
|
|
|
] ++ (lib'.attrValues self.overlays);
|
2021-12-06 07:33:03 +00:00
|
|
|
|
2023-07-30 06:16:40 +00:00
|
|
|
defaultSystem = "x86_64-linux";
|
2022-11-25 06:35:11 +00:00
|
|
|
|
|
|
|
# Just add systems here and it should add systems to the outputs.
|
2023-09-17 05:53:19 +00:00
|
|
|
systems = [
|
2023-07-30 06:16:40 +00:00
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
|
|
|
];
|
2022-03-28 00:15:40 +00:00
|
|
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
|
2021-12-08 04:20:18 +00:00
|
|
|
|
2022-09-25 03:45:44 +00:00
|
|
|
extraArgs = {
|
2023-03-13 15:46:24 +00:00
|
|
|
inherit (inputs) nix-colors;
|
2022-09-28 11:49:44 +00:00
|
|
|
|
|
|
|
# This is a variable that is used to check whether the module is
|
|
|
|
# exported or not. Useful for configuring parts of the configuration
|
|
|
|
# that is otherwise that cannot be exported for others' use.
|
2023-08-02 02:11:37 +00:00
|
|
|
_isfoodogsquaredcustom = true;
|
2022-09-25 03:45:44 +00:00
|
|
|
};
|
2022-08-17 10:43:48 +00:00
|
|
|
|
2023-06-20 06:48:38 +00:00
|
|
|
# We're considering this as the variant since we'll export the custom
|
|
|
|
# library as `lib` in the output attribute.
|
|
|
|
lib' = nixpkgs.lib.extend (final: prev:
|
|
|
|
import ./lib { lib = prev; }
|
|
|
|
// import ./lib/private.nix { lib = final; });
|
2022-02-04 12:45:24 +00:00
|
|
|
|
2023-02-05 08:27:14 +00:00
|
|
|
# The shared configuration for the entire list of hosts for this cluster.
|
|
|
|
# Take note to only set as minimal configuration as possible since we're
|
|
|
|
# also using this with the stable version of nixpkgs.
|
2023-10-28 03:53:40 +00:00
|
|
|
hostSharedConfig = { options, config, lib, pkgs, ... }: {
|
2023-12-18 10:44:27 +00:00
|
|
|
# Initialize some of the XDG base directories ourselves since it is
|
|
|
|
# used by NIX_PROFILES to properly link some of them.
|
2023-12-13 01:59:37 +00:00
|
|
|
environment.sessionVariables = {
|
|
|
|
XDG_CACHE_HOME = "$HOME/.cache";
|
|
|
|
XDG_CONFIG_HOME = "$HOME/.config";
|
|
|
|
XDG_DATA_HOME = "$HOME/.local/share";
|
|
|
|
XDG_STATE_HOME = "$HOME/.local/state";
|
|
|
|
};
|
|
|
|
|
2022-07-09 05:54:05 +00:00
|
|
|
# Only use imports as minimally as possible with the absolute
|
2022-08-27 05:30:04 +00:00
|
|
|
# requirements of a host. On second thought, only on flakes with
|
|
|
|
# optional NixOS modules.
|
2023-10-16 15:01:38 +00:00
|
|
|
imports =
|
|
|
|
# Append with our custom NixOS modules from the modules folder.
|
|
|
|
import ./modules/nixos { inherit lib; isInternal = true; }
|
|
|
|
|
2023-12-04 10:54:18 +00:00
|
|
|
# Then, make the most with the modules from the flake inputs. Take
|
|
|
|
# note importing some modules such as home-manager are as part of the
|
2023-12-08 04:35:46 +00:00
|
|
|
# declarative host config so be sure to check out
|
|
|
|
# `hostSpecificModule` function as well.
|
2023-10-16 15:01:38 +00:00
|
|
|
++ [
|
|
|
|
inputs.nur.nixosModules.nur
|
|
|
|
inputs.sops-nix.nixosModules.sops
|
|
|
|
inputs.disko.nixosModules.disko
|
2023-11-04 06:58:02 +00:00
|
|
|
inputs.nix-index-database.nixosModules.nix-index
|
2023-11-24 02:11:26 +00:00
|
|
|
inputs.nixos-wsl.nixosModules.default
|
2023-10-16 15:01:38 +00:00
|
|
|
];
|
2022-07-09 05:54:05 +00:00
|
|
|
|
2023-12-13 02:00:43 +00:00
|
|
|
# Set some extra, yeah?
|
|
|
|
_module.args = extraArgs;
|
|
|
|
|
2023-11-04 15:22:54 +00:00
|
|
|
# Find Nix files with these! Even if nix-index is already enabled, it
|
|
|
|
# is better to make it explicit.
|
|
|
|
programs.command-not-found.enable = false;
|
|
|
|
programs.nix-index.enable = true;
|
|
|
|
|
2022-10-27 07:13:30 +00:00
|
|
|
# BOOOOOOOOOOOOO! Somebody give me a tomato!
|
|
|
|
services.xserver.excludePackages = with pkgs; [ xterm ];
|
|
|
|
|
2023-10-28 03:53:40 +00:00
|
|
|
# Append with the default time servers. It is becoming more unresponsive as
|
|
|
|
# of 2023-10-28.
|
|
|
|
networking.timeServers = [
|
|
|
|
"europe.pool.ntp.org"
|
|
|
|
"asia.pool.ntp.org"
|
|
|
|
"time.cloudflare.com"
|
|
|
|
] ++ options.networking.timeServers.default;
|
|
|
|
|
2023-12-20 02:41:39 +00:00
|
|
|
# Disable channel state files. This shouldn't break any existing
|
|
|
|
# programs as long as we manage them NIX_PATH ourselves.
|
|
|
|
nix.channel.enable = lib.mkDefault false;
|
|
|
|
|
2022-08-07 02:40:19 +00:00
|
|
|
# Set several paths for the traditional channels.
|
2023-12-23 10:35:53 +00:00
|
|
|
nix.nixPath = lib.mkIf config.nix.channel.enable
|
|
|
|
(lib.mapAttrsToList
|
2022-08-10 04:24:09 +00:00
|
|
|
(name: source:
|
|
|
|
let
|
|
|
|
name' = if (name == "self") then "config" else name;
|
|
|
|
in
|
|
|
|
"${name'}=${source}")
|
|
|
|
inputs
|
2022-08-07 02:40:19 +00:00
|
|
|
++ [
|
|
|
|
"/nix/var/nix/profiles/per-user/root/channels"
|
2023-12-23 10:35:53 +00:00
|
|
|
]);
|
2021-12-06 07:33:03 +00:00
|
|
|
|
2022-07-08 22:51:16 +00:00
|
|
|
# Please clean your temporary crap.
|
2023-04-22 06:10:03 +00:00
|
|
|
boot.tmp.cleanOnBoot = lib.mkDefault true;
|
2022-07-08 22:51:16 +00:00
|
|
|
|
|
|
|
# We live in a Unicode world and dominantly English in technical fields so we'll
|
|
|
|
# have to go with it.
|
2022-09-01 15:21:26 +00:00
|
|
|
i18n.defaultLocale = lib.mkDefault "en_US.UTF-8";
|
2022-07-08 22:51:16 +00:00
|
|
|
|
2022-07-08 23:08:27 +00:00
|
|
|
# The global configuration for the home-manager module.
|
2022-09-19 02:55:31 +00:00
|
|
|
home-manager.useUserPackages = lib.mkDefault true;
|
|
|
|
home-manager.useGlobalPkgs = lib.mkDefault true;
|
2023-10-16 15:01:38 +00:00
|
|
|
home-manager.sharedModules = [ userSharedConfig ];
|
2022-07-09 05:56:36 +00:00
|
|
|
|
2022-07-17 01:36:29 +00:00
|
|
|
# Enabling some things for sops.
|
2022-09-19 02:55:31 +00:00
|
|
|
programs.gnupg.agent = lib.mkDefault {
|
2022-07-09 05:56:36 +00:00
|
|
|
enable = true;
|
|
|
|
enableSSHSupport = true;
|
|
|
|
};
|
2022-09-19 02:55:31 +00:00
|
|
|
services.openssh.enable = lib.mkDefault true;
|
2022-11-05 01:25:24 +00:00
|
|
|
|
2023-10-18 16:16:21 +00:00
|
|
|
# It's following the 'nixpkgs' flake input which should be in unstable
|
|
|
|
# branches. Not to mention, most of the system configurations should
|
|
|
|
# have this attribute set explicitly by default.
|
|
|
|
system.stateVersion = lib.mkDefault "23.11";
|
2021-11-25 11:55:30 +00:00
|
|
|
};
|
2021-11-29 05:30:57 +00:00
|
|
|
|
2022-08-06 05:58:24 +00:00
|
|
|
# The default config for our home-manager configurations. This is also to
|
|
|
|
# be used for sharing modules among home-manager users from NixOS
|
|
|
|
# configurations with `nixpkgs.useGlobalPkgs` set to `true` so avoid
|
|
|
|
# setting nixpkgs-related options here.
|
2023-08-02 07:20:26 +00:00
|
|
|
userSharedConfig = { pkgs, config, lib, ... }: {
|
2023-10-16 15:01:38 +00:00
|
|
|
imports =
|
|
|
|
# Import our own custom modules from here..
|
|
|
|
import ./modules/home-manager { inherit lib; isInternal = true; }
|
|
|
|
|
|
|
|
# ...plus a bunch of third-party modules.
|
|
|
|
++ [
|
|
|
|
inputs.nur.hmModules.nur
|
|
|
|
inputs.sops-nix.homeManagerModules.sops
|
2023-11-04 06:58:02 +00:00
|
|
|
inputs.nix-index-database.hmModules.nix-index
|
2023-10-16 15:01:38 +00:00
|
|
|
];
|
2023-06-08 04:14:52 +00:00
|
|
|
|
2023-12-13 02:00:43 +00:00
|
|
|
# Set some extra, yeah?
|
|
|
|
_module.args = extraArgs;
|
|
|
|
|
2022-08-06 05:58:24 +00:00
|
|
|
# Hardcoding this is not really great especially if you consider using
|
|
|
|
# other locales but its default values are already hardcoded so what
|
|
|
|
# the hell. For other users, they would have to do set these manually.
|
2022-08-10 04:24:09 +00:00
|
|
|
xdg.userDirs =
|
|
|
|
let
|
2022-09-19 02:55:31 +00:00
|
|
|
# The home directory-related options should be already taken care
|
|
|
|
# of at this point. It is an ABSOLUTE MUST that it is set properly
|
|
|
|
# since other parts of the home-manager config relies on it being
|
|
|
|
# set properly.
|
|
|
|
#
|
2022-11-25 06:35:11 +00:00
|
|
|
# Here are some of the common cases for setting the home directory
|
|
|
|
# options.
|
2022-09-19 02:55:31 +00:00
|
|
|
#
|
2022-11-25 06:35:11 +00:00
|
|
|
# * For exporting home-manager configurations, this is done in this
|
|
|
|
# flake definition.
|
|
|
|
# * For NixOS configs, this is done automatically by the
|
|
|
|
# home-manager NixOS module.
|
2022-09-19 02:55:31 +00:00
|
|
|
# * Otherwise, you'll have to manually set them.
|
2022-08-10 04:24:09 +00:00
|
|
|
appendToHomeDir = path: "${config.home.homeDirectory}/${path}";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
desktop = appendToHomeDir "Desktop";
|
|
|
|
documents = appendToHomeDir "Documents";
|
|
|
|
download = appendToHomeDir "Downloads";
|
|
|
|
music = appendToHomeDir "Music";
|
|
|
|
pictures = appendToHomeDir "Pictures";
|
|
|
|
publicShare = appendToHomeDir "Public";
|
|
|
|
templates = appendToHomeDir "Templates";
|
|
|
|
videos = appendToHomeDir "Videos";
|
|
|
|
};
|
2021-12-11 05:37:27 +00:00
|
|
|
|
2022-09-25 03:46:14 +00:00
|
|
|
programs.home-manager.enable = true;
|
|
|
|
|
2023-08-02 07:20:26 +00:00
|
|
|
manual = lib.mkDefault {
|
2022-07-08 22:51:16 +00:00
|
|
|
html.enable = true;
|
|
|
|
json.enable = true;
|
|
|
|
manpages.enable = true;
|
|
|
|
};
|
2023-08-02 06:51:10 +00:00
|
|
|
|
2023-08-02 07:20:26 +00:00
|
|
|
home.stateVersion = lib.mkDefault "23.11";
|
|
|
|
};
|
|
|
|
|
2023-09-11 02:14:39 +00:00
|
|
|
# This will be shared among NixOS and home-manager configurations.
|
2023-08-02 06:51:10 +00:00
|
|
|
nixSettingsSharedConfig = { config, lib, pkgs, ... }: {
|
|
|
|
# I want to capture the usual flakes to its exact version so we're
|
|
|
|
# making them available to our system. This will also prevent the
|
|
|
|
# annoying downloads since it always get the latest revision.
|
|
|
|
nix.registry =
|
|
|
|
lib.mapAttrs'
|
|
|
|
(name: flake:
|
|
|
|
let
|
|
|
|
name' = if (name == "self") then "config" else name;
|
|
|
|
in
|
|
|
|
lib.nameValuePair name' { inherit flake; })
|
|
|
|
inputs;
|
|
|
|
|
2023-12-16 11:00:09 +00:00
|
|
|
# Set the package for generating the configuration.
|
|
|
|
nix.package = lib.mkDefault pkgs.nixUnstable;
|
2023-08-02 06:51:10 +00:00
|
|
|
|
|
|
|
# Set the configurations for the package manager.
|
2023-12-19 05:08:55 +00:00
|
|
|
nix.settings = {
|
|
|
|
# Set several binary caches.
|
|
|
|
substituters = [
|
|
|
|
"https://nix-community.cachix.org"
|
|
|
|
"https://foo-dogsquared.cachix.org"
|
|
|
|
];
|
|
|
|
trusted-public-keys = [
|
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
|
|
|
"foo-dogsquared.cachix.org-1:/2fmqn/gLGvCs5EDeQmqwtus02TUmGy0ZlAEXqRE70E="
|
|
|
|
];
|
|
|
|
|
|
|
|
# Sane config for the package manager.
|
|
|
|
# TODO: Remove this after nix-command and flakes has been considered
|
|
|
|
# stable.
|
|
|
|
#
|
|
|
|
# Since we're using flakes to make this possible, we need it. Plus, the
|
|
|
|
# UX of Nix CLI is becoming closer to Guix's which is a nice bonus.
|
|
|
|
experimental-features = [ "nix-command" "flakes" "repl-flake" ];
|
|
|
|
auto-optimise-store = lib.mkDefault true;
|
|
|
|
};
|
2023-08-02 06:51:10 +00:00
|
|
|
|
|
|
|
# Stallman-senpai will be disappointed.
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
|
|
|
|
# Extend nixpkgs with our overlays except for the NixOS-focused modules
|
|
|
|
# here.
|
|
|
|
nixpkgs.overlays = overlays;
|
2021-12-06 07:33:03 +00:00
|
|
|
};
|
2023-12-08 04:35:46 +00:00
|
|
|
|
|
|
|
# A function that generates a Nix module from host metadata.
|
|
|
|
hostSpecificModule = host: metadata:
|
|
|
|
{ lib, ... }: {
|
|
|
|
imports = [
|
|
|
|
inputs.${metadata.home-manager-channel or "home-manager"}.nixosModules.home-manager
|
|
|
|
|
|
|
|
hostSharedConfig
|
|
|
|
nixSettingsSharedConfig
|
|
|
|
./hosts/${host}
|
|
|
|
];
|
|
|
|
|
|
|
|
config = lib.mkMerge [
|
2023-12-16 12:02:22 +00:00
|
|
|
{
|
|
|
|
networking.hostName = lib.mkForce metadata.hostname or host;
|
|
|
|
nixpkgs.hostPlatform = metadata._system;
|
|
|
|
}
|
2023-12-08 04:35:46 +00:00
|
|
|
|
|
|
|
(lib.mkIf (metadata ? domain)
|
|
|
|
{ networking.domain = lib.mkForce metadata.domain; })
|
|
|
|
];
|
|
|
|
};
|
2022-08-06 06:00:04 +00:00
|
|
|
in
|
|
|
|
{
|
2021-12-18 09:41:45 +00:00
|
|
|
# Exposes only my library with the custom functions to make it easier to
|
2022-07-09 06:04:17 +00:00
|
|
|
# include in other flakes for whatever reason may be.
|
2022-01-07 03:08:50 +00:00
|
|
|
lib = import ./lib { lib = nixpkgs.lib; };
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2021-12-18 09:41:45 +00:00
|
|
|
# A list of NixOS configurations from the `./hosts` folder. It also has
|
|
|
|
# some sensible default configurations.
|
2023-07-29 23:11:53 +00:00
|
|
|
nixosConfigurations =
|
|
|
|
lib'.mapAttrs
|
2023-12-08 04:35:46 +00:00
|
|
|
(host: metadata:
|
2023-07-29 23:11:53 +00:00
|
|
|
mkHost {
|
2023-12-13 03:28:45 +00:00
|
|
|
extraModules = [ (hostSpecificModule host metadata) ];
|
2023-12-08 04:35:46 +00:00
|
|
|
nixpkgs-channel = metadata.nixpkgs-channel or "nixpkgs";
|
2023-07-29 23:11:53 +00:00
|
|
|
})
|
2023-12-08 04:35:46 +00:00
|
|
|
(listImagesWithSystems images);
|
2021-11-25 11:55:30 +00:00
|
|
|
|
|
|
|
# We're going to make our custom modules available for our flake. Whether
|
|
|
|
# or not this is a good thing is debatable, I just want to test it.
|
2023-12-16 12:02:53 +00:00
|
|
|
nixosModules.default = import ./modules/nixos { lib = lib'; };
|
2021-12-06 06:55:00 +00:00
|
|
|
|
2021-12-06 09:55:40 +00:00
|
|
|
# I can now install home-manager users in non-NixOS systems.
|
2022-03-28 00:15:40 +00:00
|
|
|
# NICE!
|
2023-07-29 23:11:53 +00:00
|
|
|
homeConfigurations =
|
|
|
|
lib'.mapAttrs
|
2023-09-05 22:53:05 +00:00
|
|
|
(filename: metadata:
|
|
|
|
let
|
2023-12-19 09:55:46 +00:00
|
|
|
name = metadata.username or metadata._name or filename;
|
|
|
|
pkgs = import inputs.${metadata.nixpkgs-channel or "nixpkgs"} {
|
|
|
|
system = metadata._system;
|
|
|
|
};
|
2023-09-05 22:53:05 +00:00
|
|
|
extraModules = [
|
2023-12-10 12:22:51 +00:00
|
|
|
({ lib, pkgs, config, ... }: {
|
2023-10-02 10:15:50 +00:00
|
|
|
# Don't create the user directories since they are assumed to
|
|
|
|
# be already created by a pre-installed system (which should
|
|
|
|
# already handle them).
|
2023-12-11 08:30:00 +00:00
|
|
|
xdg.userDirs.createDirectories = lib.mkForce false;
|
2023-11-08 12:46:12 +00:00
|
|
|
|
2023-09-05 22:53:05 +00:00
|
|
|
# Setting the homely options.
|
2023-12-10 12:22:51 +00:00
|
|
|
home.username = lib.mkForce name;
|
2023-12-13 03:25:14 +00:00
|
|
|
home.homeDirectory = lib.mkForce (metadata.home-directory or "/home/${config.home.username}");
|
2023-09-05 22:53:05 +00:00
|
|
|
|
2023-12-11 08:30:00 +00:00
|
|
|
programs.home-manager.enable = lib.mkForce true;
|
|
|
|
targets.genericLinux.enable = true;
|
2023-09-05 22:53:05 +00:00
|
|
|
})
|
|
|
|
userSharedConfig
|
|
|
|
nixSettingsSharedConfig
|
2023-12-19 05:08:55 +00:00
|
|
|
./users/home-manager/${name}
|
2023-09-05 22:53:05 +00:00
|
|
|
];
|
|
|
|
in
|
|
|
|
mkHome {
|
2023-12-13 02:00:43 +00:00
|
|
|
inherit pkgs extraModules;
|
2023-09-05 22:53:05 +00:00
|
|
|
home-manager-channel = metadata.home-manager-channel or "home-manager";
|
|
|
|
})
|
2023-12-19 09:55:46 +00:00
|
|
|
(listImagesWithSystems users);
|
2021-11-29 09:56:24 +00:00
|
|
|
|
2021-12-06 09:55:40 +00:00
|
|
|
# Extending home-manager with my custom modules, if anyone cares.
|
2023-12-16 12:02:53 +00:00
|
|
|
homeModules.default = import ./modules/home-manager { lib = lib'; };
|
2021-11-29 05:30:57 +00:00
|
|
|
|
2022-07-14 00:18:34 +00:00
|
|
|
# In case somebody wants to use my stuff to be included in nixpkgs.
|
2023-09-25 10:14:56 +00:00
|
|
|
overlays = import ./overlays // {
|
|
|
|
default = final: prev: import ./pkgs { pkgs = prev; };
|
|
|
|
};
|
2022-07-14 00:18:34 +00:00
|
|
|
|
2021-12-18 09:41:45 +00:00
|
|
|
# My custom packages, available in here as well. Though, I mainly support
|
|
|
|
# "x86_64-linux". I just want to try out supporting other systems.
|
2023-01-07 08:06:34 +00:00
|
|
|
packages = forAllSystems (system:
|
2023-07-14 05:17:05 +00:00
|
|
|
inputs.flake-utils.lib.flattenTree (import ./pkgs {
|
2023-08-03 10:11:34 +00:00
|
|
|
pkgs = import nixpkgs { inherit system; };
|
2023-07-14 05:17:05 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
# This contains images that are meant to be built and distributed
|
|
|
|
# somewhere else including those NixOS configurations that are built as
|
|
|
|
# an ISO.
|
|
|
|
images =
|
2023-07-29 23:11:53 +00:00
|
|
|
forAllSystems (system:
|
|
|
|
let
|
2023-12-08 04:35:46 +00:00
|
|
|
images' = lib'.filterAttrs (host: metadata: system == metadata._system) (listImagesWithSystems images);
|
2023-07-29 23:11:53 +00:00
|
|
|
in
|
2023-08-04 02:25:05 +00:00
|
|
|
lib'.mapAttrs'
|
2023-07-29 23:11:53 +00:00
|
|
|
(host: metadata:
|
|
|
|
let
|
2023-08-04 02:25:05 +00:00
|
|
|
name = metadata._name;
|
2023-07-29 23:11:53 +00:00
|
|
|
nixpkgs-channel = metadata.nixpkgs-channel or "nixpkgs";
|
2023-12-17 03:57:14 +00:00
|
|
|
pkgs = import inputs.${nixpkgs-channel} {};
|
2023-07-29 23:11:53 +00:00
|
|
|
format = metadata.format or "iso";
|
|
|
|
in
|
2023-08-04 02:25:05 +00:00
|
|
|
lib'.nameValuePair name (mkImage {
|
2023-12-16 12:02:22 +00:00
|
|
|
inherit format pkgs;
|
2023-12-13 03:28:45 +00:00
|
|
|
extraModules = [ (hostSpecificModule host metadata) ];
|
2023-08-04 02:25:05 +00:00
|
|
|
}))
|
2023-07-29 23:11:53 +00:00
|
|
|
images');
|
2021-12-13 07:32:58 +00:00
|
|
|
|
|
|
|
# My several development shells for usual type of projects. This is much
|
|
|
|
# more preferable than installing all of the packages at the system
|
|
|
|
# configuration (or even home environment).
|
2021-12-18 09:41:45 +00:00
|
|
|
devShells = forAllSystems (system:
|
2022-03-28 00:15:40 +00:00
|
|
|
let pkgs = import nixpkgs { inherit system overlays; };
|
|
|
|
in {
|
|
|
|
default = import ./shell.nix { inherit pkgs; };
|
2023-07-08 11:41:30 +00:00
|
|
|
docs = import ./docs/shell.nix { inherit pkgs; };
|
2022-03-28 00:15:40 +00:00
|
|
|
} // (import ./shells { inherit pkgs; }));
|
2022-01-25 01:28:10 +00:00
|
|
|
|
|
|
|
# Cookiecutter templates for your mama.
|
|
|
|
templates = {
|
2022-03-28 00:15:40 +00:00
|
|
|
default = self.templates.basic-devshell;
|
2022-01-25 01:28:10 +00:00
|
|
|
basic-devshell = {
|
|
|
|
path = ./templates/basic-devshell;
|
|
|
|
description = "Basic development shell template";
|
|
|
|
};
|
2022-09-01 02:01:15 +00:00
|
|
|
basic-overlay-flake = {
|
|
|
|
path = ./templates/basic-overlay-flake;
|
|
|
|
description = "Basic overlay as a flake";
|
|
|
|
};
|
2023-05-24 10:54:07 +00:00
|
|
|
sample-nixos-template = {
|
|
|
|
path = ./templates/sample-nixos-template;
|
|
|
|
description = "Simple sample Nix flake with NixOS and home-manager";
|
|
|
|
};
|
2023-08-03 07:44:11 +00:00
|
|
|
local-ruby-nix = {
|
|
|
|
path = ./templates/local-ruby-nix;
|
|
|
|
description = "Local Ruby app development with ruby-nix";
|
|
|
|
};
|
2022-01-25 01:28:10 +00:00
|
|
|
};
|
2022-08-06 06:57:45 +00:00
|
|
|
|
|
|
|
# No amount of formatters will make this codebase nicer but it sure does
|
|
|
|
# feel like it does.
|
|
|
|
formatter =
|
2022-11-19 03:00:53 +00:00
|
|
|
forAllSystems (system: nixpkgs.legacyPackages.${system}.treefmt);
|
2022-11-13 05:49:54 +00:00
|
|
|
|
2022-11-30 00:40:49 +00:00
|
|
|
# nixops-lite (that is much more powerful than nixops itself)... in
|
|
|
|
# here!?! We got it all, son!
|
2022-11-13 05:49:54 +00:00
|
|
|
#
|
2022-11-30 00:40:49 +00:00
|
|
|
# Also, don't forget to always clean your shell history when overriding
|
|
|
|
# sensitive info such as the hostname and such. A helpful tip would be
|
|
|
|
# ignoring the shell entry by simply prefixing it with a space which most
|
|
|
|
# command-line shells have support for (e.g., Bash, zsh, fish).
|
2023-01-07 08:06:34 +00:00
|
|
|
deploy.nodes =
|
|
|
|
let
|
|
|
|
nixosConfigurations = lib'.mapAttrs'
|
|
|
|
(name: value:
|
2023-07-01 04:30:36 +00:00
|
|
|
let
|
|
|
|
metadata = images.${name};
|
|
|
|
in
|
2023-01-07 08:06:34 +00:00
|
|
|
lib'.nameValuePair "nixos-${name}" {
|
2023-06-22 16:26:04 +00:00
|
|
|
hostname = metadata.deploy.hostname or name;
|
|
|
|
autoRollback = metadata.deploy.auto-rollback or true;
|
|
|
|
magicRollback = metadata.deploy.magic-rollback or true;
|
|
|
|
fastConnection = metadata.deploy.fast-connection or true;
|
|
|
|
remoteBuild = metadata.deploy.remote-build or false;
|
2023-01-07 08:06:34 +00:00
|
|
|
profiles.system = {
|
2023-07-01 04:30:36 +00:00
|
|
|
sshUser = metadata.deploy.ssh-user or "admin";
|
2023-01-07 08:06:34 +00:00
|
|
|
user = "root";
|
2023-07-01 04:30:36 +00:00
|
|
|
path = inputs.deploy.lib.${metadata.system or defaultSystem}.activate.nixos value;
|
2023-01-07 08:06:34 +00:00
|
|
|
};
|
|
|
|
})
|
|
|
|
self.nixosConfigurations;
|
2023-02-20 11:02:28 +00:00
|
|
|
homeConfigurations = lib'.mapAttrs'
|
2023-01-07 08:06:34 +00:00
|
|
|
(name: value:
|
2023-07-01 04:30:36 +00:00
|
|
|
let
|
|
|
|
metadata = users.${name};
|
|
|
|
username = metadata.deploy.username or name;
|
|
|
|
in
|
2023-07-05 08:42:15 +00:00
|
|
|
lib'.nameValuePair "home-manager-${name}" {
|
|
|
|
hostname = metadata.deploy.hostname or name;
|
|
|
|
autoRollback = metadata.deploy.auto-rollback or true;
|
|
|
|
magicRollback = metadata.deploy.magic-rollback or true;
|
|
|
|
fastConnection = metadata.deploy.fast-connection or true;
|
|
|
|
remoteBuild = metadata.deploy.remote-build or false;
|
|
|
|
profiles.home = {
|
|
|
|
sshUser = metadata.deploy.ssh-user or username;
|
|
|
|
user = metadata.deploy.user or username;
|
|
|
|
path = inputs.deploy.lib.${metadata.system or defaultSystem}.activate.home-manager value;
|
|
|
|
};
|
|
|
|
})
|
2023-02-20 11:02:28 +00:00
|
|
|
self.homeConfigurations;
|
2023-01-07 08:06:34 +00:00
|
|
|
in
|
2023-02-20 11:02:28 +00:00
|
|
|
nixosConfigurations // homeConfigurations;
|
2022-11-13 05:49:54 +00:00
|
|
|
|
|
|
|
# How to make yourself slightly saner than before. So far the main checks
|
|
|
|
# are for deploy nodes.
|
|
|
|
checks = lib'.mapAttrs
|
|
|
|
(system: deployLib: deployLib.deployChecks self.deploy)
|
|
|
|
inputs.deploy.lib;
|
2022-11-21 12:33:58 +00:00
|
|
|
|
|
|
|
# I'm cut off from the rest of my setup with no Hydra instance yet but
|
|
|
|
# I'm sure it will grow some of them as long as you didn't put it under a
|
|
|
|
# rock.
|
2022-12-04 06:09:08 +00:00
|
|
|
hydraJobs.build-packages = forAllSystems (system: self.packages.${system});
|
2022-01-25 01:32:17 +00:00
|
|
|
};
|
2021-11-25 11:55:30 +00:00
|
|
|
}
|