Skip to content

Commit

Permalink
🚧 WIP nixpkgs 23.11
Browse files Browse the repository at this point in the history
  • Loading branch information
abbec committed Jan 4, 2024
1 parent c92d6f2 commit f84f097
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 77 deletions.
37 changes: 12 additions & 25 deletions examples/hello/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions examples/hello/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
description = "Example project demonstrating simple components using Nedryglot languages.";

inputs = {
pkgs.url = github:NixOS/nixpkgs/nixos-22.11;
nedryglot.url = path:../../;
pkgs.url = github:NixOS/nixpkgs/nixos-23.11;
nedryglot = {
url = path:../../;
inputs.nixpkgs.follows = "pkgs";
};
nedryland.follows = "nedryglot/nedryland";
};

Expand All @@ -12,7 +15,15 @@
# TODO: not necessarily
system = "x86_64-linux";

pkgs' = pkgs.legacyPackages."${system}";
pkgs' = import pkgs {
inherit system;
config = {
allowUnfreePredicate = pkg:
builtins.elem
(builtins.parseDrvName pkg.name or pkg.pname).name
[ "terraform" ];
};
};
project = import ./project.nix {
nedryland = nedryland.lib."${system}";
nedryglot = nedryglot.lib."${system}";
Expand Down
8 changes: 5 additions & 3 deletions examples/overrides/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
description = "Example project demonstrating how to override language configurations.";

inputs = {
pkgs.url = github:NixOS/nixpkgs/nixos-22.11;
nedryland.url = github:goodbyekansas/nedryland/move-to-nedryglot;
pkgs.url = github:NixOS/nixpkgs/nixos-23.11;
nedryglot.url = path:../../;
nedryland.follows = "nedryglot/nedryland";
oxalica.url = github:oxalica/rust-overlay;
};

outputs = { pkgs, nedryland, oxalica, ... }:
outputs = { pkgs, nedryglot, nedryland, oxalica, ... }:
let
# TODO: not necessarily
system = "x86_64-linux";

pkgs' = pkgs.legacyPackages."${system}";
project = import ./project.nix {
nedryglot = nedryglot.lib."${system}";
nedryland = nedryland.lib."${system}";
oxalica = oxalica.overlays.default;
pkgs = pkgs';
Expand Down
4 changes: 2 additions & 2 deletions examples/overrides/project.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ nedryland, oxalica, pkgs }:
{ nedryland, oxalica, nedryglot, pkgs }:
let
nedry = nedryland { inherit pkgs; };
in
Expand All @@ -18,7 +18,7 @@ nedry.mkProject

baseExtensions =
let
glot = import ../../default.nix { };
glot = nedryglot;
in
[
glot.languages
Expand Down
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@
url = github:goodbyekansas/nedryland/9.0.0;
inputs.nixpkgs.follows = "nixpkgs";
};

inputs.flake-utils.url = github:numtide/flake-utils;
inputs.nixpkgs.url = "nixpkgs/nixos-22.05";
inputs.nixpkgs.url = "nixpkgs/nixos-23.11";
inputs.nixpkgs_22_11.url = "nixpkgs/nixos-22.11";

outputs = { nedryland, flake-utils, nixpkgs, nixpkgs_22_11, ... }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages."${system}";
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfreePredicate = pkg:
builtins.elem
(builtins.parseDrvName pkg.name or pkg.pname).name
[ "terraform" ];
};
};
nedry = nedryland.lib."${system}" {
inherit pkgs;
};
Expand Down
4 changes: 2 additions & 2 deletions python/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ let
outputs = pythonPackage.outputs or [ "out" ] ++ [ "wheel" ];
postInstall = ''
${pythonPackage.postInstall or ""}
mkdir -p "$wheel"
cp dist/*.whl "$wheel"
mkdir -p "${builtins.placeholder "wheel"}"
cp dist/*.whl "${builtins.placeholder "wheel"}"
'';
}
);
Expand Down
3 changes: 2 additions & 1 deletion python/hooks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ let
];
extraArgs = "--rootdir=./";
};
depsAttr = if lib.versionOlder lib.version "23.05pre-git" then "deps" else "propagatedBuildInputs";
in
{
check = _: pythonPkgs:
makeSetupHook
{
name = "check-hook";
deps = with pythonPkgs; [
"${depsAttr}" = with pythonPkgs; [
findutils
(coverageWithConfig coverage)
(flake8WithConfig flake8)
Expand Down
18 changes: 9 additions & 9 deletions python/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ args@{ name
, src
, srcExclude ? [ ]
, preBuild ? ""
, format ? "setuptools"
, setuptoolsLibrary ? false
, doStandardTests ? true
, ...
Expand Down Expand Up @@ -42,9 +41,6 @@ let
} else gitignoreSource args.src;

attrs = builtins.removeAttrs args [ "srcExclude" "shellInputs" "targetSetup" "docs" "docsConfig" ];
hookAndChecks = [ (checkHook src pythonPkgs) ]
++ (resolveInputs "checkInputs" attrs.checkInputs or [ ]);


# Aside from propagating dependencies, buildPythonPackage also injects
# code into and wraps executables with the paths included in this list.
Expand Down Expand Up @@ -78,20 +74,25 @@ let
});

pythonPackageArgs = (attrs // {
inherit version format preBuild doStandardTests pythonVersion propagatedBuildInputs;
inherit version preBuild doStandardTests pythonVersion propagatedBuildInputs;
src = if lib.isStorePath src then src else filteredSrc;
pname = name;

# Don't install dependencies with pip, let nix handle that
preInstall = ''
pipInstallFlags+=('--no-deps')
${attrs.preInstall or ""}
'';

nativeCheckInputs = (lib.optional (lib.versionAtLeast lib.version "23.05pre-git") (checkHook src pythonPkgs))
++ (resolveInputs "nativeCheckInputs" attrs.nativeCheckInputs or [ ]);

# Dependencies needed for running the checkPhase. These are added to nativeBuildInputs when doCheck = true.
# Items listed in tests_require go here.
checkInputs = hookAndChecks
checkInputs = (lib.optional (lib.versionOlder lib.version "23.05pre-git") (checkHook src pythonPkgs))
++ (resolveInputs "checkInputs" attrs.checkInputs or [ ])
++ (builtins.map (input: pythonPkgs."types-${input.pname or input.name}" or null) (builtins.filter lib.isDerivation propagatedBuildInputs))
++ (lib.optional (format == "setuptools") pythonPkgs.types-setuptools);
++ (lib.optional (attrs.format or "" == "setuptools") pythonPkgs.types-setuptools);

# Build-time only dependencies. Typically executables as well
# as the items listed in setup_requires
Expand All @@ -102,8 +103,7 @@ let
buildInputs = resolveInputs "buildInputs" attrs.buildInputs or [ ];

passthru = {
shellInputs = hookAndChecks
++ [ pythonPkgs.python-lsp-server pythonPkgs.pylsp-mypy pythonPkgs.pyls-isort targetSetup ]
shellInputs = [ pythonPkgs.python-lsp-server pythonPkgs.pylsp-mypy pythonPkgs.pyls-isort targetSetup ]
++ args.shellInputs or [ ];
inherit pythonPackageArgs;
} // attrs.passthru or { };
Expand Down
3 changes: 1 addition & 2 deletions rust/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ let
{
inherit name attrs hostTriple;
mkPackage = pkgs.callPackage ./package.nix ({
inherit base hostTriple buildTriple;
rootCallPackage = callPackage;
inherit base hostTriple buildTriple python3;
} // rustToolsetArgs);
} // lib.optionalAttrs (output != null) { inherit output; };

Expand Down
24 changes: 18 additions & 6 deletions rust/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
, lib
, pkgs
, removeReferencesTo
, rootCallPackage
, pkgsBuildBuild
, symlinkJoin
, python3
, hostTriple
Expand All @@ -23,6 +23,7 @@ attrs@{ name
, ...
}:
let
rootCallPackage = pkgsBuildBuild.callPackage;
# "Compiler type" dependencies, buildPlatform = hostPlatform != targetPlatform
# host = the platform that the resulting binary will run on (i.e. the host platform of
# the produced artifact, not our host platform)
Expand Down Expand Up @@ -83,8 +84,8 @@ let
{
name = "rust-setup-hook";
substitutions = {
rustLibSrc = lib.optionalString (rustPlatform.rust.rustc ? src) rustPlatform.rustLibSrc;
addPrefixupHook = lib.optionalString (rustPlatform.rust.rustc ? src) ''
rustLibSrc = lib.optionalString (rustc ? src) rustPlatform.rustLibSrc;
addPrefixupHook = lib.optionalString (rustc ? src) ''
preFixupHooks+=(remove_rustlibsrc)
'';
};
Expand All @@ -94,7 +95,7 @@ in
base.mkDerivation
(
safeAttrs // {
inherit stdenv propagatedBuildInputs buildInputs runner checkInputs;
inherit stdenv propagatedBuildInputs runner checkInputs buildInputs;
shellCommands = {
cargo = {
script = ''
Expand Down Expand Up @@ -152,15 +153,26 @@ base.mkDerivation
&& !(builtins.any (pred: pred path type) srcExclude);

nativeBuildInputs = [
rustc
cargo
rustHooks
cacert
removeReferencesTo
]
++ (builtins.attrValues rustPlatform.rust)
++ nativeBuildInputs;

lintInputs = [
clippy
# workaround for https://github.com/NixOS/nixpkgs/issues/278508
(clippy.overrideAttrs
(a: {
pname = "${a.pname}-patched";
nativeBuildInputs = a.nativeBuildInputs or [ ] ++ [ pkgsBuildBuild.makeWrapper ];
preFixup = ''
${a.preFixup or ""}
mv $out/bin/clippy-driver $out/bin/.clippy-driver
makeWrapper $out/bin/.clippy-driver $out/bin/clippy-driver --add-flags "--sysroot ${rustc}"
'';
}))
rustfmt
];

Expand Down
6 changes: 4 additions & 2 deletions rust/rust-setuphook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
declare -a CRATEPATH=()
setup_cratepath() {
shopt -s globstar
for cratepath in $(dirname "$1"/**/Cargo.toml); do
CRATEPATH+=("$cratepath")
shopt -s nullglob

for cratepath in "$1"/**/Cargo.toml; do
CRATEPATH+=("$(dirname "$cratepath")")
done
}

Expand Down
Loading

0 comments on commit f84f097

Please sign in to comment.