nix/flake.nix

118 lines
3.2 KiB
Nix

{
description = "Arnie's nix flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
devenv = {
url = "github:cachix/devenv";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
devenv,
...
}@inputs:
let
systems = nixpkgs.lib.genAttrs [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
in
{
lib = {
forAllSystems =
function:
systems (
system:
function (
import nixpkgs {
inherit system;
overlays = [
devenv.overlays.default
];
config.allowUnfreePredicate = (pkg: builtins.elem (nixpkgs.lib.getName pkg) [ "terraform" ]);
}
)
);
golangci-config-file = ./.golangci.yml;
eslint-config-file = ./eslint.config.mjs;
cd_root = "cd $DEVENV_ROOT;";
mdtohtml-src = self.lib.forAllSystems (
pkgs: pkgs.fetchFromGitHub {
owner = "gomarkdown";
repo = "mdtohtml";
rev = "d773061d1585e9a85aded292f65459b2cb8b2131";
sha256 = "sha256-GzYiiLL0yjGK70haRjoXT1QmvAjl+N/Z8H0EBhVOhRY=";
}
);
control4-env = self.lib.forAllSystems (
pkgs:
pkgs.buildEnv {
name = "control4_env";
paths = with pkgs; [
lua5_1
lua51Packages.busted
stylua
nodejs_22
(pkgs.buildGoModule {
name = "mdtohtml";
CGO_ENABLED = 0;
src = self.lib.mdtohtml-src.${pkgs.system};
subPackages = [ "." ];
ldflags = [ "-s" "-w" ];
vendorHash = "sha256-HzHwB0XoVjmqucqyDn44NlIG2ASPzZOKv0POiOyBxrY=";
})
];
}
);
mkDevenvShell = devenv.lib.mkShell;
};
formatter = self.lib.forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
packages = self.lib.forAllSystems (pkgs: {
devenv-up = self.devShells.${pkgs.system}.default.config.procfileScript;
devenv-test = self.devShells.${pkgs.system}.default.config.test;
});
devShells = self.lib.forAllSystems (pkgs: {
default = self.lib.mkDevenvShell {
inherit inputs pkgs;
modules = [
{
scripts = {
menu = {
description = "Print this menu";
exec = ''
echo "Commands:"
echo -n '${builtins.toJSON (builtins.mapAttrs (s: value: value.description) self.devShells.${pkgs.system}.default.config.scripts)}' | \
${pkgs.jq}/bin/jq -r 'to_entries | map(" \(.key)\n" + " - \(if .value == "" then "no description provided" else .value end)") | "" + .[]'
'';
};
fix = {
exec = ''
${self.lib.cd_root}
nix fmt ./*.nix
'';
};
};
}
];
};
});
};
}