purge flake demons

This commit is contained in:
atagen 2025-07-01 00:26:18 +10:00
parent 40feebba44
commit 9d46a07857
5 changed files with 142 additions and 181 deletions

32
flake.lock generated
View file

@ -1,23 +1,5 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1733935885,
@ -36,22 +18,22 @@
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"repo": "default-linux",
"type": "github"
}
}

149
flake.nix
View file

@ -1,59 +1,45 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
nixConfig = {
extra-substituters = "https://anmonteiro.nix-cache.workers.dev";
extra-trusted-public-keys = "ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=";
systems.url = "github:nix-systems/default-linux";
};
outputs =
{
self,
nixpkgs,
flake-utils,
systems,
}:
let
forAllSystems =
function: nixpkgs.lib.genAttrs (import systems) (system: function nixpkgs.legacyPackages.${system});
version = builtins.toString self.lastModified;
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
getPkgs = builtins.attrValues;
deps = pkgs: {
minimal = getPkgs {
inherit (pkgs.ocamlPackages)
dune_3
ocaml
angstrom
angstrom-unix
ppx_inline_test
;
};
inherit (pkgs) mkShell ocamlPackages;
inherit (ocamlPackages)
dune_3
ocaml
utop
ocaml-lsp
ocamlformat
ocamlformat-rpc-lib
angstrom
angstrom-unix
ppx_inline_test
;
minimal = [
dune_3
ocaml
angstrom
angstrom-unix
ppx_inline_test
];
dev = [
utop
ocaml-lsp
ocamlformat
ocamlformat-rpc-lib
pkgs.just
];
in
{
devShells.default = mkShell {
buildInputs = minimal ++ dev;
dev = getPkgs {
inherit (pkgs.ocamlPackages)
utop
ocaml-lsp
ocamlformat
ocamlformat-rpc-lib
;
inherit (pkgs) just;
};
};
in
{
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = with (deps pkgs); minimal ++ dev;
shellHook =
let
justFile = ''
@ -82,59 +68,46 @@
printf '${justFile}' > justfile
'';
};
});
checks.default = pkgs.callPackage ./nix/test.nix {
culr = self.packages.${system}.tests;
checks = forAllSystems (pkgs: {
default = pkgs.callPackage ./nix/test.nix {
culr = self.packages.${pkgs.system}.tests;
inherit version;
};
});
packages.default = pkgs.callPackage ./nix/default.nix {
ocaml-deps = minimal;
inherit version;
};
packages.debug = pkgs.callPackage ./nix/default.nix {
debug = true;
ocaml-deps = minimal;
inherit version;
};
packages.tests = pkgs.callPackage ./nix/default.nix {
debug = true;
ocaml-deps = minimal;
doCheck = true;
inherit version;
};
}
)
// {
nixosModules.culr = import ./nix/module.nix { overlays = [ self.overlays.culr ]; };
overlays.culr =
final: prev:
packages = forAllSystems (
pkgs:
let
ocaml-deps =
let
inherit (prev.ocamlPackages)
dune_3
ocaml
angstrom
angstrom-unix
ppx_inline_test
;
in
[
dune_3
ocaml
angstrom
angstrom-unix
ppx_inline_test
];
minimal = (deps pkgs).minimal;
in
{
culr = final.callPackage ./nix/default.nix {
inherit ocaml-deps version;
culr = self.packages.${pkgs.system}.default;
default = pkgs.ocamlPackages.callPackage ./nix/default.nix {
ocaml-deps = minimal;
inherit version;
};
debug = pkgs.ocamlPackages.callPackage ./nix/default.nix {
debug = true;
ocaml-deps = minimal;
inherit version;
};
tests = pkgs.ocamlPackages.callPackage ./nix/default.nix {
debug = true;
ocaml-deps = minimal;
doCheck = true;
inherit version;
};
}
);
nixosModules.culr =
{ pkgs, ... }:
{
imports = [ ./nix/module.nix ];
programs.culr.package = self.packages.${pkgs.system}.culr;
};
};
}

View file

@ -1,51 +0,0 @@
{
pkgs,
lib,
config,
...
}: let
inherit (lib) mkIf mkEnableOption mkOption types concatStringsSep typeOf;
cfg = config.programs.culr;
in {
options.programs.culr = {
enable = mkEnableOption "culr";
pattern = mkOption {
type = with types; either str (listOf int);
default = [];
description = "colourising pattern";
};
palette = mkOption {
type = with types; listOf str;
default = [];
description = "palette to use in comma separated RGB hex eg. #0f0f0f";
};
separators = mkOption {
type = with types; str;
default = "";
description = "char list of separators to use";
};
delimiters = mkOption {
type = with types; str;
default = "";
description = "char list of delimiters to use";
};
};
config = mkIf cfg.enable {
environment.systemPackages = let inherit (pkgs) culr; in [culr];
environment.sessionVariables = {
CULR_ORDER = let
serialise = {
list = list: concatStringsSep ";" (map (i: builtins.toString i) list);
string = s: s;
};
in
mkIf (cfg.pattern != "" && cfg.pattern != [])
(serialise.${typeOf cfg.pattern}
cfg.pattern);
CULR_PALETTE = mkIf (cfg.palette != []) (concatStringsSep ";" cfg.palette);
CULR_SEP = mkIf (cfg.separators != "") (cfg.separators);
CULR_DELIM = mkIf (cfg.delimiters != "") (cfg.delimiters);
};
};
}

View file

@ -2,34 +2,35 @@
pkgs,
lib,
ocaml-deps,
ocamlPackages,
buildDunePackage,
version,
debug ? false,
doCheck ? false,
...
}:
ocamlPackages.buildDunePackage {
buildDunePackage {
pname = "culr";
version = "0.1-vivid-${version}";
minimalOCamlVersion = "5.2";
src = ./..;
nativeBuildInputs = [pkgs.git];
nativeBuildInputs = [ pkgs.git ];
buildInputs = ocaml-deps;
buildPhase =
if debug
then ''
runHook preBuild
dune build -p culr --profile debug ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postBuild
''
else ''
runHook preBuild
dune build -p culr --profile release ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postBuild
'';
if debug then
''
runHook preBuild
dune build -p culr --profile debug ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postBuild
''
else
''
runHook preBuild
dune build -p culr --profile release ''${enableParallelBuilding:+-j $NIX_BUILD_CORES}
runHook postBuild
'';
checkPhase = ''
dune runtest

View file

@ -1,4 +1,60 @@
{overlays}: {
nixpkgs.overlays = overlays;
imports = [./culr-module.nix];
{
lib,
config,
...
}:
let
inherit (lib)
mkIf
mkEnableOption
mkPackageOption
mkOption
types
concatStringsSep
typeOf
;
cfg = config.programs.culr;
in
{
options.programs.culr = {
enable = mkEnableOption "culr";
package = mkPackageOption { } "" { };
pattern = mkOption {
type = with types; either str (listOf int);
default = [ ];
description = "colourising pattern";
};
palette = mkOption {
type = with types; listOf str;
default = [ ];
description = "palette to use in comma separated RGB hex eg. #0f0f0f";
};
separators = mkOption {
type = with types; str;
default = "";
description = "char list of separators to use";
};
delimiters = mkOption {
type = with types; str;
default = "";
description = "char list of delimiters to use";
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
environment.sessionVariables = {
CULR_ORDER =
let
serialise = {
list = list: concatStringsSep ";" (map (i: builtins.toString i) list);
string = s: s;
};
in
mkIf (cfg.pattern != "" && cfg.pattern != [ ]) (serialise.${typeOf cfg.pattern} cfg.pattern);
CULR_PALETTE = mkIf (cfg.palette != [ ]) (concatStringsSep ";" cfg.palette);
CULR_SEP = mkIf (cfg.separators != "") (cfg.separators);
CULR_DELIM = mkIf (cfg.delimiters != "") (cfg.delimiters);
};
};
}