Update config and format the files

This commit is contained in:
Gabriel Arazas 2021-11-30 09:03:05 +08:00
parent 2260012fc9
commit 0f6cf8871f
14 changed files with 166 additions and 15 deletions

14
Makefile Normal file
View File

@ -0,0 +1,14 @@
ROOT := /mnt
HOST := ni
.PHONY: install
install:
nixos-install --flake ".#${HOST}" --root ${ROOT}
.PHONY: switch
switch:
nixos-rebuild --flake ".#${HOST}" switch
.PHONY: test
test:
nixos-rebuild --flake ".#${HOST}" dry-activate

View File

@ -1,5 +1,5 @@
= foo-dogsquared's NixOS config
:todo:
:toc:
This is my NixOS config as a link:https://www.tweag.io/blog/2020-05-25-flakes/[Nix flake].

6
flake.lock generated
View File

@ -42,11 +42,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1638129630,
"narHash": "sha256-vaYC1DhrR1nao2rQ8fUf4PNhBLfSeCi2LVrDXTxUu1Y=",
"lastModified": 1638189734,
"narHash": "sha256-Vks5UgpFqbrSNi3RXaozVWAVEfueplN2WBPs2bRajHA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9f25a8ac3a985ba213f775b19750efefdecc9974",
"rev": "f366af7a1b3891d9370091ab03150d3a6ee138fa",
"type": "github"
},
"original": {

View File

@ -76,6 +76,23 @@ in rec {
};
in lib.listToAttrs (lib.mapAttrsToList collect files);
/* Collect all modules (results from `filesToAttr`) into a list.
Signature:
attrs -> [ function ]
Where:
- `attrs` is the set of modules and their path.
Returns:
- A list of imported modules.
Example:
modulesToList (filesToAttr ../modules)
=> [ <lambda> <lambda> <lambda> ]
*/
modulesToList = attrs:
let paths = lib.collect builtins.isPath attrs;
in builtins.map (path: import path) paths;
/* Create a NixOS system through a given host folder.
It will automate some of the things such as making the last component
of the path as the hostname.
@ -132,9 +149,8 @@ in rec {
getUsers = users:
let
userModules = filesToAttr ../users;
validUsers =
lib.filter (user: lib.elem user (lib.attrNames userModules)) users;
in lib.filterAttrs (n: _: lib.elem n validUsers) userModules;
invalidUsernames = [ "config" "modules" ];
in lib.filterAttrs (n: _: !lib.elem n invalidUsernames) userModules;
/* Create an attribute set from two lists (or a zip).

View File

@ -37,6 +37,7 @@ in {
cmake # The poster boy for the hated build system.
direnv # The power of local development environment.
gnumake # Make your life easier with GNU Make.
moreutils # Less is more but more utilities, the merrier.
];
})

View File

@ -20,7 +20,6 @@ in
gnomeExtensions.arcmenu
gnomeExtensions.x11-gestures
gnomeExtensions.gsconnect
];
};
}

View File

@ -3,14 +3,18 @@
let
cfg = config.modules.users;
userModules = lib.filesToAttr ../users;
invalidUsernames = [ "config" "modules" ];
userModules = lib.filterAttrs (n: _: !lib.elem n invalidUsernames)
(lib.filesToAttr ../users);
homeManagerModules =
lib.filterAttrs (n: _: n == "modules") (lib.filesToAttr ../users);
users = lib.attrNames userModules;
nonexistentUsers = lib.filter (name: !lib.elem name users) cfg.users;
mkUser = user: path:
mkUser = user: modulePath:
let
userModule = import path;
userModule = import modulePath;
defaultConfig = {
home.username = user;
home.homeDirectory = "/home/${user}";
@ -22,7 +26,7 @@ let
isNormalUser = true;
extraGroups = [ "wheel" ];
};
home-manager.users.${user} = userModule // defaultConfig;
home-manager.users.${user} = import modulePath;
};
in {
options.modules.users = {
@ -45,6 +49,7 @@ in {
{
home-manager.useUserPackages = true;
home-manager.useGlobalPkgs = true;
home-manager.sharedModules = lib.modulesToList homeManagerModules;
}
] ++ (lib.mapAttrsToList mkUser userModules);

View File

@ -1,5 +1,7 @@
{ pkgs ? import <nixpkgs> { } }:
{
doggo = pkgs.callPackage ./doggo.nix { };
libcs50 = pkgs.callPackage ./libcs50.nix { };
tic-80 = pkgs.callPackage ./tic-80.nix { };
}

32
pkgs/doggo.nix Normal file
View File

@ -0,0 +1,32 @@
{ stdenv, lib, fetchFromGitHub, buildGoModule, installShellFiles }:
buildGoModule rec {
pname = "doggo";
version = "0.4.1";
subPackages = [ "cmd/doggo" "cmd/api" ];
src = fetchFromGitHub {
owner = "mr-karan";
repo = "doggo";
rev = "v${version}";
sha256 = "sha256-TG1pWLf/aB/5clzBYdbZcGZb+64oV9olT5xezUWay/M=";
};
ldflags = [ "-X main.buildVersion=v${version}" ];
nativeBuildInputs = [ installShellFiles ];
vendorSha256 = "sha256-eyR1LuaMkyQqIaV4GN/7Nr1TkdHr+M3C3z/pyNF0Vo4=";
postInstall = ''
# The binary names come from the Makefile only without the '.bin. extension.
mv $out/bin/{api,doggo-api}
installShellCompletion completions/doggo.{fish,zsh}
'';
meta = with lib; {
description = "HTTP DNS client for humans.";
homepage = "https://github.com/mr-karan/doggo";
license = licenses.mit;
};
}

28
pkgs/tic-80.nix Normal file
View File

@ -0,0 +1,28 @@
{ stdenv, lib, alsaLib, cmake, fetchFromGitHub, freeglut, gtk3, libGLU, libglvnd
, mesa, pkgconfig }:
stdenv.mkDerivation rec {
pname = "tic-80";
version = "ad6fac460480ca2eff25e6ef142460b9ff7bdcef";
src = fetchFromGitHub {
owner = "nesbox";
repo = "TIC-80";
rev = "8ba1ae484fed6904a76894804a99f4ea1e0af754";
sha256 = "sha256-/BL7wbD/qeAWVJXAF4B6v5iD8SjjHKg48DBAjcXSa/I=";
fetchSubmodules = true;
};
nativeBuildInputs = [ cmake pkgconfig ];
buildInputs = [ alsaLib freeglut gtk3 libGLU libglvnd mesa ];
cmakeFlags = [ "-DBUILD_PRO=ON" ];
meta = with lib; {
description = "A fantasy computer with built-in game dev tools.";
homepage = "https://tic80.com/";
license = licenses.mit;
};
}

View File

@ -13,8 +13,12 @@
# My custom modules.
modules = {
alacritty.enable = true;
i18n.enable = true;
dev.enable = true;
desktop = {
enable = true;
graphics.enable = true;
audio.enable = true;
};
};
}

View File

@ -9,7 +9,7 @@ in
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [ alacritty ];
xdg.configFile."alacritty" = {
source = ../config/alacritty/alacritty.yml;
source = ../config/alacritty;
recursive = true;
};
};

39
users/modules/desktop.nix Normal file
View File

@ -0,0 +1,39 @@
# Enables all of my usual setup for desktop-oriented stuff.
{ config, options, lib, pkgs, ... }:
let
cfg = config.modules.desktop;
in
{
options.modules.desktop = {
enable = lib.mkEnableOption "Enable installations of desktop apps.";
graphics.enable = lib.mkEnableOption "Install graphics-related apps.";
audio.enable = lib.mkEnableOption "Install audio-related apps.";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
(lib.mkIf cfg.graphics.enable {
home.packages = with pkgs; [
aseprite # Pixel art wannabe tool.
blender # 3D modelling wannabe tool.
inkscape # Illustration wannabe tool.
gimp # Photo editing wannabe tool.
krita # Digital art wannabe tool.
];
})
(lib.mkIf cfg.audio.enable {
home.packages = with pkgs; [
ardour
musescore
# Trying to
yabridge
yabridgectl
helvum
];
services.easyeffects.enable = true;
})
]);
}

View File

@ -16,6 +16,9 @@ in
lazygit # Git interface for the lazy.
fzf # A fuzzy finder that enables fuzzy finding not furry finding, a common misconception.
gopass # An improved version of the password manager for hipsters.
perl534Packages.vidir # Bulk rename for your organizing needs.
zellij # A modern tmux?
lf # File manager in the terminal, really.
# Coreutils replacement.
fd # Oh nice, a more reliable `find`.
@ -23,12 +26,20 @@ in
exa # Oh nice, a shinier `ls`.
bat # dog > bat > cat
];
})
(lib.mkIf cfg.shell.enable {
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
programs.zoxide.enable = true;
programs.starship = {
enable = true;
settings = {
add_newline = false;
};
};
})
]);
}