nixos-config/flake.nix

249 lines
8.7 KiB
Nix

{
description = "Flake of LibrePhoenix";
outputs = inputs@{ self, nixpkgs, nixpkgs-stable, emacs-pin-nixpkgs,
kdenlive-pin-nixpkgs, home-manager, nix-doom-emacs, nix-straight, stylix,
blocklist-hosts, hyprland-plugins, rust-overlay, org-nursery, org-yaap,
org-side-tree, org-timeblock, org-krita, phscroll, mini-frame, ... }:
let
# ---- SYSTEM SETTINGS ---- #
systemSettings = {
system = "x86_64-linux"; # system arch
hostname = "snowfire"; # hostname
profile = "personal"; # select a profile defined from my profiles directory
timezone = "America/Chicago"; # select timezone
locale = "en_US.UTF-8"; # select locale
bootMode = "uefi"; # uefi or bios
bootMountPath = "/boot"; # mount path for efi boot partition; only used for uefi boot mode
grubDevice = ""; # device identifier for grub; only used for legacy (bios) boot mode
};
# ----- USER SETTINGS ----- #
userSettings = rec {
username = "emmet"; # username
name = "Emmet"; # name/identifier
email = "emmet@librephoenix.com"; # email (used for certain configurations)
dotfilesDir = "~/.dotfiles"; # absolute path of the local repo
theme = "uwunicorn-yt"; # selcted theme from my themes directory (./themes/)
wm = "hyprland"; # Selected window manager or desktop environment; must select one in both ./user/wm/ and ./system/wm/
# window manager type (hyprland or x11) translator
wmType = if (wm == "hyprland") then "wayland" else "x11";
browser = "qutebrowser"; # Default browser; must select one from ./user/app/browser/
defaultRoamDir = "Personal.p"; # Default org roam directory relative to ~/Org
term = "alacritty"; # Default terminal command;
font = "Intel One Mono"; # Selected font
fontPkg = pkgs.intel-one-mono; # Font package
editor = "emacsclient"; # Default editor;
# editor spawning translator
# generates a command that can be used to spawn editor inside a gui
# EDITOR and TERM session variables must be set in home.nix or other module
# I set the session variable SPAWNEDITOR to this in my home.nix for convenience
spawnEditor = if (editor == "emacsclient") then
"emacsclient -c -a 'emacs'"
else
(if ((editor == "vim") ||
(editor == "nvim") ||
(editor == "nano")) then
"exec " + term + " -e " + editor
else
editor);
};
# create patched nixpkgs
nixpkgs-patched =
(import nixpkgs { system = systemSettings.system; }).applyPatches {
name = "nixpkgs-patched";
src = nixpkgs;
patches = [ ./patches/emacs-no-version-check.patch ];
};
# configure pkgs
# use nixpkgs if running a server (homelab or worklab profile)
# otherwise use patched nixos-unstable nixpkgs
pkgs = (if ((systemSettings.profile == "homelab") || (systemSettings.profile == "worklab"))
then
pkgs-stable
else
(import nixpkgs-patched {
system = systemSettings.system;
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
overlays = [ rust-overlay.overlays.default ];
}));
pkgs-stable = import nixpkgs-stable {
system = systemSettings.system;
config = {
allowUnfree = true;
allowUnfreePredicate = (_: true);
};
};
pkgs-emacs = import emacs-pin-nixpkgs {
system = systemSettings.system;
};
pkgs-kdenlive = import kdenlive-pin-nixpkgs {
system = systemSettings.system;
};
# configure lib
# use nixpkgs if running a server (homelab or worklab profile)
# otherwise use patched nixos-unstable nixpkgs
lib = (if ((systemSettings.profile == "homelab") || (systemSettings.profile == "worklab"))
then
nixpkgs-stable.lib
else
nixpkgs.lib);
# Systems that can run tests:
supportedSystems = [ "aarch64-linux" "i686-linux" "x86_64-linux" ];
# Function to generate a set based on supported systems:
forAllSystems = inputs.nixpkgs.lib.genAttrs supportedSystems;
# Attribute set of nixpkgs for each system:
nixpkgsFor =
forAllSystems (system: import inputs.nixpkgs { inherit system; });
in {
homeConfigurations = {
user = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
(./. + "/profiles" + ("/" + systemSettings.profile)
+ "/home.nix") # load home.nix from selected PROFILE
# inputs.nix-flatpak.homeManagerModules.nix-flatpak # Declarative flatpaks
];
extraSpecialArgs = {
# pass config variables from above
inherit pkgs-stable;
inherit pkgs-emacs;
inherit pkgs-kdenlive;
inherit systemSettings;
inherit userSettings;
inherit (inputs) nix-doom-emacs;
inherit (inputs) org-nursery;
inherit (inputs) org-yaap;
inherit (inputs) org-side-tree;
inherit (inputs) org-timeblock;
inherit (inputs) org-krita;
inherit (inputs) phscroll;
inherit (inputs) mini-frame;
#inherit (inputs) nix-flatpak;
inherit (inputs) stylix;
inherit (inputs) hyprland-plugins;
};
};
};
nixosConfigurations = {
system = lib.nixosSystem {
system = systemSettings.system;
modules = [
(./. + "/profiles" + ("/" + systemSettings.profile)
+ "/configuration.nix")
]; # load configuration.nix from selected PROFILE
specialArgs = {
# pass config variables from above
inherit pkgs-stable;
inherit systemSettings;
inherit userSettings;
inherit (inputs) stylix;
inherit (inputs) blocklist-hosts;
};
};
};
packages = forAllSystems (system:
let pkgs = nixpkgsFor.${system};
in {
default = self.packages.${system}.install;
install = pkgs.writeShellApplication {
name = "install";
runtimeInputs = with pkgs; [ git ]; # I could make this fancier by adding other deps
text = ''${./install.sh} "$@"'';
};
});
apps = forAllSystems (system: {
default = self.apps.${system}.install;
install = {
type = "app";
program = "${self.packages.${system}.install}/bin/install";
};
});
};
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
nixpkgs-stable.url = "nixpkgs/nixos-23.11";
emacs-pin-nixpkgs.url = "nixpkgs/f72123158996b8d4449de481897d855bc47c7bf6";
kdenlive-pin-nixpkgs.url = "nixpkgs/cfec6d9203a461d9d698d8a60ef003cac6d0da94";
home-manager.url = "github:nix-community/home-manager/master";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nix-doom-emacs.url = "github:nix-community/nix-doom-emacs";
nix-doom-emacs.inputs.nixpkgs.follows = "emacs-pin-nixpkgs";
nix-straight.url = "github:librephoenix/nix-straight.el/pgtk-patch";
nix-straight.flake = false;
nix-doom-emacs.inputs.nix-straight.follows = "nix-straight";
eaf = {
url = "github:emacs-eaf/emacs-application-framework";
flake = false;
};
eaf-browser = {
url = "github:emacs-eaf/eaf-browser";
flake = false;
};
org-nursery = {
url = "github:chrisbarrett/nursery";
flake = false;
};
org-yaap = {
url = "gitlab:tygrdev/org-yaap";
flake = false;
};
org-side-tree = {
url = "github:localauthor/org-side-tree";
flake = false;
};
org-timeblock = {
url = "github:ichernyshovvv/org-timeblock";
flake = false;
};
org-krita = {
url = "github:lepisma/org-krita";
flake = false;
};
phscroll = {
url = "github:misohena/phscroll";
flake = false;
};
mini-frame = {
url = "github:muffinmad/emacs-mini-frame";
flake = false;
};
stylix.url = "github:danth/stylix";
rust-overlay.url = "github:oxalica/rust-overlay";
blocklist-hosts = {
url = "github:StevenBlack/hosts";
flake = false;
};
hyprland-plugins = {
url = "github:hyprwm/hyprland-plugins";
flake = false;
};
};
}