2021-11-25 11:55:30 +00:00
|
|
|
{
|
|
|
|
description = "foo-dogsquared's NixOS config as a flake";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2021-12-06 10:12:00 +00:00
|
|
|
|
2021-12-18 09:41:45 +00:00
|
|
|
# We're using this library for other functions, mainly testing.
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
|
2021-12-11 05:37:27 +00:00
|
|
|
# Managing home configurations.
|
2021-11-25 11:55:30 +00:00
|
|
|
home-manager.url = "github:nix-community/home-manager";
|
|
|
|
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2022-01-02 00:48:15 +00:00
|
|
|
# This is what AUR strives to be.
|
|
|
|
nur.url = "github:nix-community/NUR";
|
|
|
|
nur.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
2021-12-11 05:37:27 +00:00
|
|
|
# Managing your secrets.
|
2021-11-25 11:55:30 +00:00
|
|
|
agenix.url = "github:ryantm/agenix";
|
|
|
|
agenix.inputs.nixpkgs.follows = "nixpkgs";
|
2021-12-06 07:33:03 +00:00
|
|
|
|
2021-12-18 09:41:45 +00:00
|
|
|
# Easy access to development environments.
|
|
|
|
devshell.url = "github:numtide/devshell";
|
|
|
|
|
2021-12-06 07:33:03 +00:00
|
|
|
# Overlays.
|
|
|
|
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
|
2022-01-02 00:40:01 +00:00
|
|
|
emacs-overlay.url = "github:nix-community/emacs-overlay";
|
|
|
|
|
2021-12-26 09:33:00 +00:00
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
|
|
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
2021-11-25 11:55:30 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 10:12:00 +00:00
|
|
|
outputs = inputs@{ self, nixpkgs, home-manager, ... }:
|
2021-11-25 11:55:30 +00:00
|
|
|
let
|
2022-01-02 14:30:00 +00:00
|
|
|
# The order here is important(?).
|
2021-12-06 07:33:03 +00:00
|
|
|
overlays = [
|
|
|
|
# Put my custom packages to be available.
|
|
|
|
(self: super: import ./pkgs { pkgs = super; })
|
|
|
|
|
|
|
|
# Neovim nightly!
|
|
|
|
inputs.neovim-nightly-overlay.overlay
|
2021-12-26 09:33:00 +00:00
|
|
|
|
2022-01-02 00:40:01 +00:00
|
|
|
# Emacs unstable version!
|
|
|
|
inputs.emacs-overlay.overlay
|
|
|
|
|
2021-12-26 09:33:00 +00:00
|
|
|
# Rust overlay for them ease of setting up Rust toolchains.
|
|
|
|
inputs.rust-overlay.overlay
|
2022-01-02 00:48:15 +00:00
|
|
|
|
|
|
|
# Access to NUR.
|
|
|
|
inputs.nur.overlay
|
2021-12-06 07:33:03 +00:00
|
|
|
];
|
|
|
|
|
2021-12-18 09:41:45 +00:00
|
|
|
forAllSystems = f:
|
|
|
|
nixpkgs.lib.genAttrs inputs.flake-utils.lib.defaultSystems
|
|
|
|
(system: f system);
|
2021-12-08 04:20:18 +00:00
|
|
|
|
2021-11-29 09:56:24 +00:00
|
|
|
libExtended = nixpkgs.lib.extend (final: prev:
|
2021-12-18 09:41:45 +00:00
|
|
|
(import ./lib { lib = final; }) // {
|
2021-12-08 04:20:18 +00:00
|
|
|
flakeUtils = (import ./lib/flake-utils.nix {
|
|
|
|
inherit inputs;
|
|
|
|
lib = final;
|
|
|
|
});
|
|
|
|
});
|
2021-11-25 11:55:30 +00:00
|
|
|
|
2021-12-06 07:33:03 +00:00
|
|
|
# The default configuration for our NixOS systems.
|
2021-11-25 11:55:30 +00:00
|
|
|
hostDefaultConfig = {
|
2021-12-18 09:41:45 +00:00
|
|
|
# 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 = {
|
|
|
|
# I'm narcissistic so I want my config to be one of the flakes in the registry.
|
|
|
|
config.flake = self;
|
2021-12-06 07:33:03 +00:00
|
|
|
|
2021-12-19 09:39:18 +00:00
|
|
|
# All of the important flakes will be included.
|
2021-12-18 09:41:45 +00:00
|
|
|
nixpkgs.flake = nixpkgs;
|
|
|
|
home-manager.flake = home-manager;
|
2021-12-19 09:39:18 +00:00
|
|
|
agenix.flake = inputs.agenix;
|
2022-01-02 00:48:15 +00:00
|
|
|
nur.flake = inputs.nur;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Set several binary caches.
|
|
|
|
nix = {
|
2022-01-03 09:29:49 +00:00
|
|
|
binaryCaches = [ "https://nix-community.cachix.org" "https://foo-dogsquared.cachix.org" ];
|
2022-01-02 00:48:15 +00:00
|
|
|
binaryCachePublicKeys = [
|
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
2022-01-03 09:29:49 +00:00
|
|
|
"foo-dogsquared.cachix.org-1:/2fmqn/gLGvCs5EDeQmqwtus02TUmGy0ZlAEXqRE70E="
|
2022-01-02 00:48:15 +00:00
|
|
|
];
|
2021-12-18 09:41:45 +00:00
|
|
|
};
|
2021-12-06 07:33:03 +00:00
|
|
|
|
2021-11-25 11:55:30 +00:00
|
|
|
# Stallman-senpai will be disappointed.
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
2021-11-29 09:56:24 +00:00
|
|
|
|
2021-12-02 13:48:44 +00:00
|
|
|
# Extend nixpkgs with our own package set.
|
2021-12-06 07:33:03 +00:00
|
|
|
nixpkgs.overlays = overlays;
|
2021-12-02 13:48:44 +00:00
|
|
|
|
2021-12-18 09:41:45 +00:00
|
|
|
# Please clean your temporary crap.
|
|
|
|
boot.cleanTmpDir = true;
|
|
|
|
|
2021-11-25 11:55:30 +00:00
|
|
|
# We live in a Unicode world and dominantly English in technical fields so we'll
|
|
|
|
# have to go with it.
|
|
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
2021-11-29 09:56:24 +00:00
|
|
|
|
2021-11-25 11:55:30 +00:00
|
|
|
# Sane config for the package manager.
|
|
|
|
# TODO: Remove this after nix-command and flakes has been considered stable.
|
2021-11-29 05:30:57 +00:00
|
|
|
#
|
2021-12-18 09:41:45 +00:00
|
|
|
# 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.
|
2021-11-25 11:55:30 +00:00
|
|
|
nix.extraOptions = ''
|
|
|
|
experimental-features = nix-command flakes
|
|
|
|
'';
|
|
|
|
};
|
2021-11-29 05:30:57 +00:00
|
|
|
|
2021-12-06 07:33:03 +00:00
|
|
|
# The default config for our home-manager configurations.
|
|
|
|
userDefaultConfig = {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
|
2022-01-02 14:30:00 +00:00
|
|
|
extraModules = [{
|
|
|
|
# To be able to use the most of our config as possible, we want both to
|
|
|
|
# use the same overlays.
|
|
|
|
nixpkgs.overlays = overlays;
|
2021-12-06 07:33:03 +00:00
|
|
|
|
2022-01-02 14:30:00 +00:00
|
|
|
# Stallman-senpai will be disappointed. :(
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
2021-12-11 05:37:27 +00:00
|
|
|
|
2022-01-02 14:30:00 +00:00
|
|
|
# Let home-manager to manage itself.
|
|
|
|
programs.home-manager.enable = true;
|
|
|
|
}];
|
2021-12-06 07:33:03 +00:00
|
|
|
};
|
2021-11-25 11:55:30 +00:00
|
|
|
in {
|
2021-12-18 09:41:45 +00:00
|
|
|
# Exposes only my library with the custom functions to make it easier to
|
|
|
|
# include in other flakes.
|
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.
|
2021-12-06 09:55:40 +00:00
|
|
|
nixosConfigurations = libExtended.mapAttrsRecursive
|
2021-12-06 06:55:00 +00:00
|
|
|
(host: path: libExtended.flakeUtils.mkHost path hostDefaultConfig)
|
2021-11-29 09:56:24 +00:00
|
|
|
(libExtended.filesToAttr ./hosts);
|
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.
|
2021-12-02 13:48:44 +00:00
|
|
|
nixosModules = libExtended.mapAttrsRecursive (_: path: import path)
|
2021-12-06 06:55:00 +00:00
|
|
|
(libExtended.filesToAttr ./modules/nixos);
|
|
|
|
|
2021-12-06 09:55:40 +00:00
|
|
|
# I can now install home-manager users in non-NixOS systems.
|
2022-01-02 14:30:00 +00:00
|
|
|
# NICE? (TODO: Please test it in the future before saying these things.)
|
2021-12-06 09:55:40 +00:00
|
|
|
homeManagerConfigurations = libExtended.mapAttrs
|
|
|
|
(_: path: libExtended.flakeUtils.mkUser path userDefaultConfig)
|
|
|
|
(libExtended.filesToAttr ./users/home-manager);
|
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.
|
|
|
|
homeManagerModules = libExtended.mapAttrsRecursive (_: path: import path)
|
|
|
|
(libExtended.filesToAttr ./modules/home-manager);
|
2021-11-29 05:30:57 +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.
|
2022-01-02 14:30:00 +00:00
|
|
|
packages = forAllSystems (system:
|
|
|
|
import ./pkgs { pkgs = import nixpkgs { inherit system overlays; }; });
|
2021-12-13 07:32:58 +00:00
|
|
|
|
2022-01-01 12:14:50 +00:00
|
|
|
# The development environment for this flake.
|
|
|
|
devShell = forAllSystems (system:
|
2022-01-02 14:30:00 +00:00
|
|
|
import ./shell.nix { pkgs = import nixpkgs { inherit system overlays; }; });
|
2022-01-01 12:14:50 +00:00
|
|
|
|
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:
|
2021-12-26 09:33:00 +00:00
|
|
|
import ./shells {
|
|
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
|
|
|
});
|
2021-11-25 11:55:30 +00:00
|
|
|
};
|
|
|
|
}
|