Skip to content

Commit

Permalink
✨ Add support for nixpkgs up to 23.11
Browse files Browse the repository at this point in the history
Note that for newer versions of nixpkgs, this also requires a new
Nedryland version.
  • Loading branch information
abbec committed Jan 9, 2024
1 parent c92d6f2 commit 3bd023f
Show file tree
Hide file tree
Showing 44 changed files with 2,127 additions and 766 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- `gen-default-crates` command to generate the list of default crates shipped with
Nedryglot.
- Support for nixpkgs versions up to 23.11

## [2.0.1] - 2023-12-05

### Fixed
Expand Down
204 changes: 103 additions & 101 deletions c/default.nix
Original file line number Diff line number Diff line change
@@ -1,109 +1,111 @@
let self =
args@{ base
, lib
, pkgs
, platforms ? { }
, extraAttrs ? { }
# TODO: remove generateDocs in next major. It is renamed to enableDoxygen to be
# consistent with make-derivation.nix
, generateDocs ? true
, enableDoxygen ? true
, components
, mathjax ? null
}:
let
enableDoxygen' =
if args ? generateDocs then
lib.trivial.warn
''
generateDocs is deprecated, use enableDoxygen instead.
enableDoxygen can also be used on derivation-level.
''
generateDocs
else
enableDoxygen;
mathjaxDefaultVersion = "3.2.2";
mathjax' =
if mathjax == null then
builtins.fetchurl
{
url = "https://cdn.jsdelivr.net/npm/mathjax@${mathjaxDefaultVersion}/es5/tex-svg.js";
sha256 = "sha256:10m80cpdhk1jqvqvkzy8qls7nmsra77fx7rrq4snk0s46z1msafl";
} else mathjax;
let
self =
args@{ base
, lib
, pkgs
, platforms ? { }
, extraAttrs ? { }
# TODO: remove generateDocs in next major. It is renamed to enableDoxygen to be
# consistent with make-derivation.nix
, generateDocs ? true
, enableDoxygen ? true
, components
, mathjax ? null
}:
let
enableDoxygen' =
if args ? generateDocs then
lib.trivial.warn
''
generateDocs is deprecated, use enableDoxygen instead.
enableDoxygen can also be used on derivation-level.
''
generateDocs
else
enableDoxygen;
mathjaxDefaultVersion = "3.2.2";
mathjax' =
if mathjax == null then
builtins.fetchurl
{
url = "https://cdn.jsdelivr.net/npm/mathjax@${mathjaxDefaultVersion}/es5/tex-svg.js";
sha256 = "sha256:10m80cpdhk1jqvqvkzy8qls7nmsra77fx7rrq4snk0s46z1msafl";
} else mathjax;

inner =
{ name
, pkgs
, stdenv ? pkgs.stdenv
, output ? null
, platformOverrides ? _: { }
}:
let
factory = pkgs.callPackage (import ./make-derivation.nix platformOverrides)
{
inherit base stdenv components;
targetName = name;
mathjax = mathjax';
};
inner =
{ name
, pkgs
, stdenv ? pkgs.stdenv
, output ? null
, platformOverrides ? _: { }
}:
let
factory = pkgs.callPackage (import ./make-derivation.nix platformOverrides)
{
inherit base stdenv components;
targetName = name;
mathjax = mathjax';
};

finalPlatform = factory:
{
inherit name pkgs;
__functor = _self: factory;
overrideFactory = overrides:
finalPlatform (
factory.override overrides);
} // lib.optionalAttrs (output != null) { inherit output; };
in
(finalPlatform factory);
finalPlatform = factory:
{
inherit name pkgs;
__functor = _self: factory;
overrideFactory = overrides:
finalPlatform (
factory.override overrides);
} // lib.optionalAttrs (output != null) { inherit output; };
in
finalPlatform factory;

mkPlatform = lib.makeOverridable inner;
mkPlatform = lib.makeOverridable inner;

platforms' = {
_default = mkPlatform {
inherit pkgs;
name = "_default";
};
} // platforms;
platforms' = {
_default = mkPlatform {
inherit pkgs;
name = "_default";
};
} // platforms;

createPlatformTargets = attrsOrFn:
lib.mapAttrs'
(name: platform: {
name = platform.output or name;
value = platform attrsOrFn;
})
platforms';
createPlatformTargets = attrsOrFn:
lib.mapAttrs'
(name: platform: {
name = platform.output or name;
value = platform attrsOrFn;
})
platforms';

toComponent = componentFactory: targets:
componentFactory
({
name = targets._default.name;
version = targets._default.version;
} // targets // lib.optionalAttrs (targets._default.enableDoxygen or enableDoxygen') {
docs.api = targets._default.doc;
});
in
extraAttrs // rec {
inherit mkPlatform;
platforms = platforms' // {
override = overridePlatforms;
};
toComponent = componentFactory: targets:
componentFactory
({
inherit (targets._default) name;
inherit (targets._default) version;
} // targets // lib.optionalAttrs (targets._default.enableDoxygen or enableDoxygen') {
docs.api = targets._default.doc;
});
in
extraAttrs // rec {
inherit mkPlatform;
platforms = platforms' // {
override = overridePlatforms;
};

name = "c/c++";
emoji = "🦕";
description = ''
C/C++
'';
name = "c/c++";
emoji = "🦕";
description = ''
C/C++
'';

overrideAttrs = f: self (args // {
extraAttrs = (extraAttrs // (f extraAttrs));
});
overridePlatforms = f: self (args // {
platforms = (platforms' // (f platforms'));
});
} // (
builtins.listToAttrs
(builtins.map
(t: { name = "mk${t}"; value = attrsOrFn: toComponent base."mk${t}" (createPlatformTargets attrsOrFn); })
[ "Library" "Client" "Service" ]));
in self
overrideAttrs = f: self (args // {
extraAttrs = extraAttrs // (f extraAttrs);
});
overridePlatforms = f: self (args // {
platforms = platforms' // (f platforms');
});
} // (
builtins.listToAttrs
(builtins.map
(t: { name = "mk${t}"; value = attrsOrFn: toComponent base."mk${t}" (createPlatformTargets attrsOrFn); })
[ "Library" "Client" "Service" ]));
in
self
10 changes: 5 additions & 5 deletions c/make-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ let
if builtins.isFunction attrsOrFn' then
attrsOrFn'
else
{}: attrsOrFn';
_: attrsOrFn';

fn = args:
let
attrs = (attrsFn args);
mkDerivationArgs = ({
attrs = attrsFn args;
mkDerivationArgs = {
inherit stdenv;
doCheck = true;
strictDeps = true;
Expand Down Expand Up @@ -165,13 +165,13 @@ let
};
}
// attrs.shellCommands or { };
});
};

platformAttrs = mkDerivationArgs // (platformOverrides mkDerivationArgs);
attrs' = platformAttrs // (overrideAttrs platformAttrs);

in
(base.mkDerivation attrs');
base.mkDerivation attrs';

splicedComponents = base.mapComponentsRecursive
(_path: component:
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{}:
_:
{
languages = import ./languages.nix;
protobuf = import ./protobuf.nix;
Expand Down
10 changes: 6 additions & 4 deletions docs/src/rust/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ To ease writing of multiple such expressions there's a CLI tool
flake. Use `gen-crate-expression --help` for usage information.

A set of crates has also been generated and ships with nedryglot under
`base.languages.rust.crates`. These are roughly equivalent to the crates
available in [Rust Playground](https://play.rust-lang.org/). This default crate
set can be overridden by making an extension. This extension overrides the crate
set with a set of one crate:
`base.languages.rust.crates`. These are roughly equivalent to the crates available in
[Rust Playground](https://play.rust-lang.org/) (that is, the 100 most downloaded crates on
[crates.io](https://crates.io/crates?sort=downloads)). This default crate set can be
overridden by making an extension. This extension overrides the crate set with a set of
one crate:

```nix
{ base }:
{
Expand Down
23 changes: 17 additions & 6 deletions examples/hello/extensions/windows-runner.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{ writeScriptBin
, openssh
, wineWowPackages
, wine64
, bash
, makeSetupHook
, writeTextFile
, xvfb-run
}:
makeSetupHook
{
Expand Down Expand Up @@ -52,17 +53,27 @@ makeSetupHook
elif [ -z "$NEDRYGLOT_DONT_USE_WINE" ]; then
echo "🍷 NEDRYGLOT_WINDOWS_HOST not set, trying wine..."
cacheFolder="''${XDG_CACHE_HOME:-$HOME/.cache}"/nedryglot/
if [ ! -w "$HOME" ]; then
cacheFolder=$(mktemp -d --tmpdir nedryglot-wine-XXXXX)
wineCommand="${wine64}/bin/wine64"
wineArgs=()
if [ -z "''${IN_NIX_SHELL:-}" ]; then
cacheFolder="$NIX_BUILD_TOP"/home/.cache/nedryglot
HOME="$NIX_BUILD_TOP"/home
mkdir -p "$HOME"
wineCommand="${xvfb-run}/bin/xvfb-run $wineCommand"
fi
mkdir -p "$cacheFolder/.wine"
cacheFolder="$cacheFolder"
export WINEPREFIX="$cacheFolder"/.wine
export WINEDEBUG=fixme-all,warn-all
export WINEDLLOVERRIDES='mscoree,mshtml='
echo "🍾 Starting wineserver..."
${wineWowPackages.stable}/bin/wineserver --persistent=300 || echo "🥂 Wineserver already running"
${wineWowPackages.stable}/bin/wine64 "$@"
if [ -n "''${IN_NIX_SHELL:-}" ]; then
echo "🍾 Starting wineserver..."
${wine64}/bin/wineserver --persistent=300 || echo "🥂 Wineserver already running"
fi
$wineCommand "''${wineArgs[@]}" "$@"
else
echo "Please set NEDRYGLOT_WINDOWS_HOST to a Windows host where you have SSH access."
exit 1
Expand Down
Loading

0 comments on commit 3bd023f

Please sign in to comment.