Skip to content

Commit

Permalink
imp: only allow one file-variant
Browse files Browse the repository at this point in the history
- don't implement two variants (singleton & multi-output)
- it's too complicated
- upstream will remove singular, that is `defaultX` variants soon
  • Loading branch information
blaggacao committed Feb 2, 2022
1 parent d7f1d36 commit 979d9e5
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 254 deletions.
59 changes: 32 additions & 27 deletions cells/std/cli.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,36 @@
}:
let
nixpkgs = inputs.nixpkgs;
shell =
nixpkgs.eggDerivation
{
name = "shell-0.4";
src =
nixpkgs.fetchegg
{
name = "shell";
version = "0.4";
sha256 = "sha256-TVZBzvlVegDLNU3Nz3w92E7imXGw6HYOq+vm2amM+/w=";
};
buildInputs = [ ];
};
in
nixpkgs.stdenv.mkDerivation
{
name = "std";
meta.description = "nix shortcut for projects that conform to Standard";
src = ./cli;
dontInstall = true;
nativeBuildInputs = [ nixpkgs.chicken ];
buildInputs = with nixpkgs.chickenPackages.chickenEggs; [ matchable srfi-13 shell ];
propagatedBuildInputs = [ nixpkgs.git ];
buildPhase = ''
mkdir -p $out/bin
csc -o $out/bin/std -static "$src/main.scm"
'';
}
{
"" =
let
shell =
nixpkgs.eggDerivation
{
name = "shell-0.4";
src =
nixpkgs.fetchegg
{
name = "shell";
version = "0.4";
sha256 = "sha256-TVZBzvlVegDLNU3Nz3w92E7imXGw6HYOq+vm2amM+/w=";
};
buildInputs = [ ];
};
in
nixpkgs.stdenv.mkDerivation
{
name = "std";
meta.description = "nix shortcut for projects that conform to Standard";
src = ./cli;
dontInstall = true;
nativeBuildInputs = [ nixpkgs.chicken ];
buildInputs = with nixpkgs.chickenPackages.chickenEggs; [ matchable srfi-13 shell ];
propagatedBuildInputs = [ nixpkgs.git ];
buildPhase = ''
mkdir -p $out/bin
csc -o $out/bin/std -static "$src/main.scm"
'';
};
}
49 changes: 0 additions & 49 deletions cells/std/devShell.nix

This file was deleted.

52 changes: 52 additions & 0 deletions cells/std/devShells.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# SPDX-FileCopyrightText: 2022 The Standard Authors
# SPDX-FileCopyrightText: 2022 Kevin Amado <kamadorueda@gmail.com>
#
# SPDX-License-Identifier: Unlicense
{ inputs
, system
}:
let
nixpkgs = inputs.nixpkgs.extend inputs.devshell.overlay;
alejandra = inputs.alejandra.defaultPackage.${system.host.system};
treefmt = inputs.treefmt.defaultPackage.${system.host.system};
stdProfile = inputs.self.devshellProfiles.${system.host.system}.std;
in
{
"" =
nixpkgs.devshell.mkShell
(
{ extraModulesPath
, pkgs
, ...
}:
{
name = "Standard";
cellsFrom = "./cells";
packages = [
# formatters
alejandra
nixpkgs.shfmt
nixpkgs.nodePackages.prettier
];
commands = [
{
package = nixpkgs.treefmt;
category = "formatters";
}
{
package = nixpkgs.editorconfig-checker;
category = "formatters";
}
{
package = nixpkgs.reuse;
category = "legal";
}
];
imports = [ "${extraModulesPath}/git/hooks.nix" stdProfile ];
git.hooks = {
enable = true;
pre-commit.text = builtins.readFile ./devShells/pre-commit.sh;
};
}
);
}
File renamed without changes.
2 changes: 1 addition & 1 deletion cells/std/devshellProfiles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, system
}:
let
std = inputs.self.cli.${ system.host.system }.std;
std = inputs.self.cli.${system.host.system}.std;
nixpkgs = inputs.nixpkgs;
in
{
Expand Down
86 changes: 36 additions & 50 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@
inputs:
let
nixpkgs = inputs.nixpkgs;
validate = import ./validators.nix { inherit inputs organelleName organellePaths; };
# organelleName is constructed from the singleton name if defined, else form the plural
organelleName = organelle: organelle.m or organelle.o;
# organellePaths are constructed from the specified organelles
organellePaths =
cellsFrom: cell: organelle:
(
if organelle ? o
then { onePath = "${cellsFrom}/${cell}/${organelle.o}.nix"; }
else { }
)
// (
if organelle ? m
then { manyPath = "${cellsFrom}/${cell}/${organelle.m}.nix"; }
else { }
);
runnables = attrs: validate.Organelle (attrs // { clade = "runnables"; });
installables = attrs: validate.Organelle (attrs // { clade = "installables"; });
functions = attrs: validate.Organelle (attrs // { clade = "functions"; });
validate = import ./validators.nix { inherit nixpkgs systems organellePath; };
organellePath = cellsFrom: cell: organelle: "${cellsFrom}/${cell}/${organelle.name}.nix";
runnables =
name:
validate.Organelle
{
inherit name;
clade = "runnables";
};
installables =
name:
validate.Organelle
{
inherit name;
clade = "installables";
};
functions =
name:
validate.Organelle
{
inherit name;
clade = "functions";
};
grow =
let
defaultSystems =
Expand All @@ -47,24 +51,22 @@
"aarch64-apple-darwin"
"aarch64-unknown-linux-gnu"
];
host = builtins.attrNames inputs.self.systems;
host = builtins.attrNames systems;
};
in
{ inputs
, cellsFrom
, organelles ? [
{
m = "library";
name = "library";
clade = "functions";
}
{
o = "app";
m = "apps";
name = "apps";
clade = "runnables";
}
{
o = "package";
m = "packages";
name = "packages";
clade = "installables";
}
]
Expand Down Expand Up @@ -149,21 +151,19 @@
if res != { }
then
(
{ "${organelleName organelle}".${ system.build.system } = applySuffixes res; }
{ "${organelle.name}".${system.build.system} = applySuffixes res; }
// (
if
(organelle.clade == "installables" || organelle.clade == "runnables")
&& as-nix-cli-epiphyte
then { packages.${ system.build.system } = applySuffixes res; }
then { packages.${system.build.system} = applySuffixes res; }
else { }
)
// (
if organelle.clade == "runnables" && as-nix-cli-epiphyte
then
{
apps.${ system.build.system } =
builtins.mapAttrs (_: toFlakeApp) (applySuffixes res);
}
then {
apps.${system.build.system} = builtins.mapAttrs (_: toFlakeApp) (applySuffixes res);
}
else { }
)
)
Expand All @@ -177,13 +177,10 @@
loadCellOrganelle =
cell: organelle: cellArgs:
let
onePath = (organellePaths cellsFrom cell organelle).onePath or null;
manyPath = (organellePaths cellsFrom cell organelle).manyPath or null;
path = organellePath cellsFrom cell organelle;
in
if onePath != null && builtins.pathExists onePath
then { "" = validate.OnePathImport organelle cellsFrom cell (import onePath cellArgs); }
else if manyPath != null && builtins.pathExists manyPath
then validate.ManyPathImport organelle cellsFrom cell (import manyPath cellArgs)
if builtins.pathExists path
then validate.ManyPathImport organelle cellsFrom cell (import path cellArgs)
else { };
toFlakeApp =
drv:
Expand Down Expand Up @@ -217,18 +214,7 @@
inherit inputs;
# as-nix-cli-epiphyte = false;
cellsFrom = ./cells;
organelles = [
(
runnables
{
o = "devShell";
# the effective output name for nix to discover
m = "devShells";
}
)
(runnables { o = "cli"; })
(functions { m = "devshellProfiles"; })
];
organelles = [ (runnables "devShells") (runnables "cli") (functions "devshellProfiles") ];
systems = [
{
# GNU/Linux 64 bits
Expand Down
2 changes: 1 addition & 1 deletion plugins/templates/src/create/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}:
{
testDefault =
inputs.self.library.${ system.build.system }.create-build
inputs.self.library.${system.build.system}.create-build
{
name = "default";
placeholders = {
Expand Down
Loading

0 comments on commit 979d9e5

Please sign in to comment.