diff --git a/flake.lock b/flake.lock index 1eaa414..2c4ee74 100644 --- a/flake.lock +++ b/flake.lock @@ -31,10 +31,27 @@ "type": "github" } }, + "nixpkgs-julia": { + "locked": { + "lastModified": 1694073329, + "narHash": "sha256-F6+k1FSgtFSXaGSQqf00u/jBHhvUvrsTx9qjEWAk0E0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ddadf5f46ac96423efbd67228ffe84361743c253", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "refs/pull/225513/head", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "call-flake": "call-flake", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-julia": "nixpkgs-julia" } } }, diff --git a/flake.nix b/flake.nix index 3775fdb..3327b3f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,27 +1,43 @@ { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nixpkgs-julia.url = "github:NixOS/nixpkgs/?ref=refs/pull/225513/head"; call-flake.url = "github:divnix/call-flake"; }; - outputs = inputs: let - std = inputs.call-flake ./nix/std; + outputs = + inputs: + let + std = inputs.call-flake ./nix/std; eachSystem = inputs.nixpkgs.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; - in (eachSystem (system: std.${system})) // { - inherit (std) lib packages devShells overlays; - templates = { - devshell = { - description = "The devshell template which contains several Julia Packages"; - path = ./templates/dev; + src = std.inputs.omnibus.inputs.flops.haumea.pops.default.setInit { + load = { + src = ./nix/src; + inputs = std.inputs // inputs; + }; }; - jlrs = { - description = "The tempalte which contains jlrs development of Nix"; - path = ./templates/jlrs; + in + (eachSystem (system: std.${system})) + // { + inherit (std) + lib + packages + devShells + overlays + ; + templates = { + devshell = { + description = "The devshell template which contains several Julia Packages"; + path = ./templates/dev; + }; + jlrs = { + description = "The tempalte which contains jlrs development of Nix"; + path = ./templates/jlrs; + }; }; }; - }; } diff --git a/nix/std/cells/julia2nix/compiler/default.nix b/nix/std/cells/julia2nix/compiler/default.nix index aa49c70..b5140df 100644 --- a/nix/std/cells/julia2nix/compiler/default.nix +++ b/nix/std/cells/julia2nix/compiler/default.nix @@ -1,5 +1 @@ -{ - inputs, - cell, -}: { -} +{ inputs, cell }: { } diff --git a/nix/std/cells/julia2nix/nixago/Manifest.toml b/nix/std/cells/julia2nix/configs/Manifest.toml similarity index 100% rename from nix/std/cells/julia2nix/nixago/Manifest.toml rename to nix/std/cells/julia2nix/configs/Manifest.toml diff --git a/nix/std/cells/julia2nix/nixago/Project.toml b/nix/std/cells/julia2nix/configs/Project.toml similarity index 100% rename from nix/std/cells/julia2nix/nixago/Project.toml rename to nix/std/cells/julia2nix/configs/Project.toml diff --git a/nix/std/cells/julia2nix/nixago/default.nix b/nix/std/cells/julia2nix/configs/default.nix similarity index 54% rename from nix/std/cells/julia2nix/nixago/default.nix rename to nix/std/cells/julia2nix/configs/default.nix index 022a109..58babbd 100644 --- a/nix/std/cells/julia2nix/nixago/default.nix +++ b/nix/std/cells/julia2nix/configs/default.nix @@ -1,7 +1,5 @@ -{ - inputs, - cell, -}: let +{ inputs, cell }: +let inherit (inputs) nixpkgs; l = inputs.nixpkgs.lib // builtins; inherit (nixpkgs) stdenv; @@ -26,24 +24,36 @@ chmod +x $out/bin/*.jl ''; package = cell.lib.julia-wrapped { - makeWrapperArgs = [ - "--add-flags --compile=min" - ]; + makeWrapperArgs = [ "--add-flags --compile=min" ]; }; }; -in { + configs = + let + inputs' = (inputs.omnibus.pops.flake.setSystem nixpkgs.system).inputs; + in + inputs.omnibus.pops.configs.addLoadExtender { load.inputs.inputs = inputs'; }; + inherit (configs.layouts.default) treefmt lefthook conform; +in +{ inherit juliaFormatter; - # treefmt = std-data-collection.data.configs.treefmt { - # data.formatter.prettier = { - # excludes = ["Manifest.toml" "Project.toml" "generated.json" "julia2nix.toml"]; - # }; - # data.formatter.nix = { - # excludes = ["generated.nix"]; - # }; - # data.formatter.julia = l.mkIf stdenv.isLinux { - # command = "${juliaFormatter}/bin/format.jl"; - # includes = ["*.jl"]; - # }; - # }; + treefmt = treefmt // { + custom = { + data.formatter.prettier = { + excludes = [ + "Manifest.toml" + "Project.toml" + "generated.json" + "julia2nix.toml" + ]; + }; + data.formatter.nix = { + excludes = [ "generated.nix" ]; + }; + data.formatter.julia = l.mkIf stdenv.isLinux { + command = "${juliaFormatter}/bin/format.jl"; + includes = [ "*.jl" ]; + }; + }; + }; } diff --git a/nix/std/cells/julia2nix/nixago/format.jl b/nix/std/cells/julia2nix/configs/format.jl similarity index 100% rename from nix/std/cells/julia2nix/nixago/format.jl rename to nix/std/cells/julia2nix/configs/format.jl diff --git a/nix/std/cells/julia2nix/nixago/julia2nix.toml b/nix/std/cells/julia2nix/configs/julia2nix.toml similarity index 100% rename from nix/std/cells/julia2nix/nixago/julia2nix.toml rename to nix/std/cells/julia2nix/configs/julia2nix.toml diff --git a/nix/std/cells/julia2nix/devshellProfiles/checks.nix b/nix/std/cells/julia2nix/devshellProfiles/checks.nix index ccbdb32..1ec0822 100644 --- a/nix/std/cells/julia2nix/devshellProfiles/checks.nix +++ b/nix/std/cells/julia2nix/devshellProfiles/checks.nix @@ -1,12 +1,11 @@ +{ inputs, cell }: { - inputs, - cell, -}: { config, lib, pkgs, ... -}: { +}: +{ commands = [ { name = "checks-GR"; diff --git a/nix/std/cells/julia2nix/devshellProfiles/default.nix b/nix/std/cells/julia2nix/devshellProfiles/default.nix index d328754..f29e039 100644 --- a/nix/std/cells/julia2nix/devshellProfiles/default.nix +++ b/nix/std/cells/julia2nix/devshellProfiles/default.nix @@ -1,8 +1,7 @@ +{ inputs, cell }@args: +let +in { - inputs, - cell, -} @ args: let -in { packages = import ./packages.nix args; checks = import ./checks.nix args; dev = import ./dev.nix args; diff --git a/nix/std/cells/julia2nix/devshellProfiles/dev.nix b/nix/std/cells/julia2nix/devshellProfiles/dev.nix index 97f12d7..6e7f5b1 100644 --- a/nix/std/cells/julia2nix/devshellProfiles/dev.nix +++ b/nix/std/cells/julia2nix/devshellProfiles/dev.nix @@ -1,19 +1,18 @@ +{ inputs, cell }: { - inputs, - cell, -}: { config, lib, pkgs, ... -}: { +}: +{ commands = lib.optionals pkgs.stdenv.buildPlatform.isLinux [ { name = "jlfmt"; category = "dev"; help = "Julia formatter"; command = '' - ${cell.nixago.juliaFormatter}/bin/format.jl "$@" + ${cell.configs.juliaFormatter}/bin/format.jl "$@" ''; } ]; diff --git a/nix/std/cells/julia2nix/devshellProfiles/nightly.nix b/nix/std/cells/julia2nix/devshellProfiles/nightly.nix index 7ffb1ed..b8f4777 100644 --- a/nix/std/cells/julia2nix/devshellProfiles/nightly.nix +++ b/nix/std/cells/julia2nix/devshellProfiles/nightly.nix @@ -1,17 +1,18 @@ +{ inputs, cell }: { - inputs, - cell, -}: { config, lib, pkgs, ... -}: { - commands = lib.optionals (pkgs.system != "x86_64-darwin") [ - # { - # name = "julia-nightly"; - # command = "${cell.packages.julia_nightly-bin}/bin/julia"; - # help = "julia nightly version"; - # } - ]; +}: +{ + commands = + lib.optionals (pkgs.system != "x86_64-darwin") + [ + # { + # name = "julia-nightly"; + # command = "${cell.packages.julia_nightly-bin}/bin/julia"; + # help = "julia nightly version"; + # } + ]; } diff --git a/nix/std/cells/julia2nix/devshellProfiles/packages.nix b/nix/std/cells/julia2nix/devshellProfiles/packages.nix index 89d4f5d..4b7f4ca 100644 --- a/nix/std/cells/julia2nix/devshellProfiles/packages.nix +++ b/nix/std/cells/julia2nix/devshellProfiles/packages.nix @@ -1,17 +1,16 @@ +{ inputs, cell }: { - inputs, - cell, -}: { config, lib, pkgs, ... -}: let +}: +let inherit (cell) packages; -in { +in +{ commands = - [ - ] + [ ] ++ lib.optionals (pkgs.system == "x86_64-darwin") [ { # FIXME: 1.8.0 init issue @@ -37,8 +36,9 @@ in { } ]; - packages = with pkgs; - lib.optionals pkgs.stdenv.isLinux [] + packages = + with pkgs; + lib.optionals pkgs.stdenv.isLinux [ ] ++ [ alejandra nixUnstable diff --git a/nix/std/cells/julia2nix/devshellProfiles/update.nix b/nix/std/cells/julia2nix/devshellProfiles/update.nix index dc58e2f..606101a 100644 --- a/nix/std/cells/julia2nix/devshellProfiles/update.nix +++ b/nix/std/cells/julia2nix/devshellProfiles/update.nix @@ -1,12 +1,11 @@ +{ inputs, cell }: { - inputs, - cell, -}: { config, lib, pkgs, ... -}: { +}: +{ commands = [ { name = "nvfetcher-update"; diff --git a/nix/std/cells/julia2nix/devshells/default.nix b/nix/std/cells/julia2nix/devshells/default.nix index fedf548..a7ebb33 100644 --- a/nix/std/cells/julia2nix/devshells/default.nix +++ b/nix/std/cells/julia2nix/devshells/default.nix @@ -1,12 +1,13 @@ -{ - inputs, - cell, -} @ args: let +{ inputs, cell }@args: +let l = nixpkgs.lib // builtins; + inherit (std) lib; inherit (inputs) nixpkgs std self; in - l.mapAttrs (_: std.lib.dev.mkShell) { - default = {extraModulesPath, ...}: { +l.mapAttrs (_: std.lib.dev.mkShell) { + default = + { extraModulesPath, ... }: + { name = "Julia2Nix"; git.hooks = { @@ -15,7 +16,9 @@ in }; nixago = [ - # cell.nixago.treefmt + (lib.dev.mkNixago std.lib.cfg.treefmt cell.configs.treefmt.default + cell.configs.treefmt.custom + ) ]; imports = @@ -65,15 +68,7 @@ in } ]; }; - packages = {pkgs, ...}: { - imports = [ - cell.devshellProfiles.packages - ]; - }; + packages = { pkgs, ... }: { imports = [ cell.devshellProfiles.packages ]; }; - update = {...}: { - imports = [ - cell.devshellProfiles.update - ]; - }; - } + update = { ... }: { imports = [ cell.devshellProfiles.update ]; }; +} diff --git a/nix/std/cells/julia2nix/entrypoints/default.nix b/nix/std/cells/julia2nix/entrypoints/default.nix index 8db7c8a..573698d 100644 --- a/nix/std/cells/julia2nix/entrypoints/default.nix +++ b/nix/std/cells/julia2nix/entrypoints/default.nix @@ -1,25 +1,24 @@ -{ - inputs, - cell, -}: let - inherit (inputs.std-ext.writers.lib) writeShellApplication; +{ inputs, cell }: +let + inherit (nixpkgs) writeShellApplication; inherit (inputs) nixpkgs; -in { - mkdoc = let - juliaDoc = cell.lib.buildEnv { - name = "julia-doc"; - src = ./doc; - package = cell.lib.julia-wrapped { - package = cell.packages.julia_19-bin; +in +{ + mkdoc = + let + juliaDoc = cell.lib.buildEnv { + name = "julia-doc"; + src = ./doc; + package = cell.lib.julia-wrapped { package = cell.packages.julia_19-bin; }; }; - }; - in + in writeShellApplication { name = "mkdoc"; - runtimeInputs = [ - # juliaDoc - nixpkgs.julia_19-bin - ]; + runtimeInputs = + [ + # juliaDoc + nixpkgs.julia_19-bin + ]; text = '' julia --project="$*" -e 'using Pkg; Pkg.develop(PackageSpec(; path=pwd())); Pkg.instantiate();' julia --project="$*" "$*"/make.jl deploy @@ -27,40 +26,39 @@ in { ''; }; - ion = let - julia-ion = - (cell.lib.buildEnv { - name = "julia-ion"; - src = ./ion; - extraDepot = { - extraJulia2nix = { - fetchzip.artifact-1fce04a1a7eedfdf2b0b81ca9001494525764e11 = { - name = "artifacts/1fce04a1a7eedfdf2b0b81ca9001494525764e11"; - sha256 = "sha256-YlrXTPJLJGjHLjoVkuygwtTV6kFUIO2VHZXwf3COIt0="; - stripRoot = false; - url = "https://pkg.julialang.org/artifact/1fce04a1a7eedfdf2b0b81ca9001494525764e11#artifact.tar.gz"; + ion = + let + julia-ion = + (cell.lib.buildEnv { + name = "julia-ion"; + src = ./ion; + extraDepot = { + extraJulia2nix = { + fetchzip.artifact-1fce04a1a7eedfdf2b0b81ca9001494525764e11 = { + name = "artifacts/1fce04a1a7eedfdf2b0b81ca9001494525764e11"; + sha256 = "sha256-YlrXTPJLJGjHLjoVkuygwtTV6kFUIO2VHZXwf3COIt0="; + stripRoot = false; + url = "https://pkg.julialang.org/artifact/1fce04a1a7eedfdf2b0b81ca9001494525764e11#artifact.tar.gz"; + }; }; }; - }; - package = cell.lib.julia-wrapped { - package = cell.packages.julia_19-bin; - }; - }) - .overrideAttrs (old: { - buildInputs = old.buildInputs ++ [nixpkgs.rsync]; - postInstall = '' + package = cell.lib.julia-wrapped { package = cell.packages.julia_19-bin; }; + }).overrideAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ nixpkgs.rsync ]; + postInstall = '' - $out/bin/julia -e 'using Ion; Ion.comonicon_install()'; - # make sure we can write the ./julia/bin/* in our $out/store - rsync -avzhr $HOME/.julia/ $out - ''; - }); - in + $out/bin/julia -e 'using Ion; Ion.comonicon_install()'; + # make sure we can write the ./julia/bin/* in our $out/store + rsync -avzhr $HOME/.julia/ $out + ''; + } + ); + in writeShellApplication { name = "julia-ion"; - runtimeInputs = [ - julia-ion - ]; + runtimeInputs = [ julia-ion ]; text = '' ion "$@" ''; diff --git a/nix/std/cells/julia2nix/lib/default.nix b/nix/std/cells/julia2nix/lib/default.nix index 854f162..8e76814 100644 --- a/nix/std/cells/julia2nix/lib/default.nix +++ b/nix/std/cells/julia2nix/lib/default.nix @@ -1,15 +1,17 @@ +{ inputs, cell }: +let + nixpkgs = inputs.nixpkgs.appendOverlays [ cell.overlays.default ]; +in { - inputs, - cell, -}: let - nixpkgs = inputs.nixpkgs.appendOverlays [ - cell.overlays.default - ]; -in { - inherit (nixpkgs.lib) installBin installApp buildDepot buildEnv buildProject julia-wrapped; + inherit (nixpkgs.lib) + installBin + installApp + buildDepot + buildEnv + buildProject + julia-wrapped + ; - /* - patches ["a" "b"] - */ + # patches ["a" "b"] # patches = list: ; } diff --git a/nix/std/cells/julia2nix/overlays/builder/default.nix b/nix/std/cells/julia2nix/overlays/builder/default.nix index 817e7e3..e5ccff2 100644 --- a/nix/std/cells/julia2nix/overlays/builder/default.nix +++ b/nix/std/cells/julia2nix/overlays/builder/default.nix @@ -5,22 +5,24 @@ makeWrapper, lib, ... -}: { +}: +{ package ? julia_19-bin, - extraLibs ? [], + extraLibs ? [ ], src, importManifest ? src + "/Manifest.toml", importProject ? src + "/Project.toml", - extraBuildInputs ? [], + extraBuildInputs ? [ ], julia2nix ? src + "/julia2nix.toml", precompile ? true, extraInstallPhase ? "", extraStartup ? "", - makeWrapperArgs ? [], - extraDepot ? {}, + makeWrapperArgs ? [ ], + extraDepot ? { }, saveRegistry ? false, ... -} @ args: let +}@args: +let # Extra libraries for Julia's LD_LIBRARY_PATH. # Recent Julia packages that use Artifacts.toml to specify their dependencies # shouldn't need this. @@ -30,84 +32,91 @@ # Wrapped Julia with libraries and environment variables. # Note: setting The PYTHON environment variable is recommended to prevent packages # from trying to obtain their own with Conda. - depotPath = lib.buildDepot (lib.recursiveUpdate {inherit julia2nix;} extraDepot); + depotPath = lib.buildDepot ( + lib.recursiveUpdate { inherit julia2nix; } extraDepot + ); in - stdenv.mkDerivation { - name = (lib.importTOML importProject).name or args.name; - buildInputs = [makeWrapper] ++ extraBuildInputs; - inherit src precompile makeWrapperArgs depotPath; +stdenv.mkDerivation { + name = (lib.importTOML importProject).name or args.name; + buildInputs = [ makeWrapper ] ++ extraBuildInputs; + inherit + src + precompile + makeWrapperArgs + depotPath + ; - preInstall = '' - mkdir -p $out - mkdir -p $out/config + preInstall = '' + mkdir -p $out + mkdir -p $out/config - export HOME=$(pwd) - echo "Copying dependencies" - export JULIA_DEPOT_PATH=$out - cp -rf --no-preserve=mode,ownership ${depotPath}/packages $out - if [ -d "${depotPath}/artifacts" ]; then - cp -rf --no-preserve=mode,ownership ${depotPath}/artifacts $out - fi + export HOME=$(pwd) + echo "Copying dependencies" + export JULIA_DEPOT_PATH=$out + cp -rf --no-preserve=mode,ownership ${depotPath}/packages $out + if [ -d "${depotPath}/artifacts" ]; then + cp -rf --no-preserve=mode,ownership ${depotPath}/artifacts $out + fi - cp -rf --no-preserve=mode,ownership ${importProject} Project.toml - cp -rf --no-preserve=mode,ownership ${importManifest} Manifest.toml + cp -rf --no-preserve=mode,ownership ${importProject} Project.toml + cp -rf --no-preserve=mode,ownership ${importManifest} Manifest.toml - cat > $out/startup.jl < $out/startup.jl < $out/${path}/deps/deps.jl <