some stuff for quickly spinning up a nix project

init

belsanti.xyz 35d4b4f1

verified
Changed files
+74
templates
all-systems
all-systems-unfree
+9
LICENSE
···
+
MIT License
+
+
Copyright (c) 2025 quasigod
+
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+9
README.md
···
+
# quix
+
+
This is just some stuff I use to quickly spin up a nix project. I would often just use `nix flake init -t github:hercules-ci/flake-parts`, but that's overkill for simple projects and adds an extra input for others to deal with.
+
+
I add this flake to my registry, so I can use `nix flake init -t quix#all-systems`.
+
+
Right now its just `all-systems` templates, since every time I need a `forAllSystems` function I would just go copy it from the last place I saw it (which in this case came from [Isabel Roses "I'm not mad, I'm disappointed"](https://isabelroses.com/blog/im-not-mad-im-disappointed/)). I've been using it enough recently that searching for it each time started to feel a little tedious, so here we are.
+
+
In the future I'll probably add some devshells and extra templates that I find useful. I also want to add a script that will open up a little TUI to select a template/devshell to use, easily accessible with `nix run quix`. I actually already wrote this script at some point, but now I can't find it.
+17
flake.nix
···
+
{
+
description = "My development shell template";
+
outputs =
+
{ ... }:
+
{
+
templates = {
+
all-systems = {
+
path = ./templates/all-systems;
+
description = "A basic flake with a forAllSystem function";
+
};
+
all-systems-unfree = {
+
path = ./templates/all-systems-unfree;
+
description = "A basic flake with a forAllSystems function and allowed unfree packages";
+
};
+
};
+
};
+
}
+24
templates/all-systems-unfree/flake.nix
···
+
{
+
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+
+
outputs =
+
{ nixpkgs, ... }:
+
let
+
forAllSystems =
+
function:
+
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
+
system:
+
function (
+
import nixpkgs {
+
inherit system;
+
config.allowUnfree = true;
+
}
+
)
+
);
+
in
+
{
+
packages = forAllSystems (pkgs: {
+
default = pkgs.callPackage ./default.nix { };
+
});
+
};
+
}
+15
templates/all-systems/flake.nix
···
+
{
+
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+
+
outputs = { nixpkgs, ... }: let
+
forAllSystems =
+
function:
+
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
+
system: function nixpkgs.legacyPackages.${system}
+
);
+
in {
+
packages = forAllSystems (pkgs: {
+
default = pkgs.callPackage ./default.nix { };
+
});
+
};
+
}