Skip to content

Commit

Permalink
Eliminate dead code (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetkov authored Oct 23, 2022
1 parent 6b86495 commit 2ce1a33
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 32 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
steps:
- run: exit 0
needs:
- check-dead-code
- tests

tests:
Expand Down Expand Up @@ -44,3 +45,14 @@ jobs:
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: run tests
run: ./ci/run-tests.sh ${{ matrix.test_args }}

check-dead-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
- uses: cachix/cachix-action@v11
with:
name: deadnix
- name: check for dead code
run: nix run github:astro/deadnix -- .
1 change: 0 additions & 1 deletion checks/cargoAudit.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ cargoAudit
, fetchFromGitHub
, lib
, linkFarmFromDrvs
, runCommandLocal
}:
Expand Down
1 change: 0 additions & 1 deletion checks/compilesFresh.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{ buildDepsOnly
, cargoBuild
, jq
}:

Expand Down
2 changes: 1 addition & 1 deletion checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ in

customCargoTargetDirectory =
let
simple = self.simple.overrideAttrs (old: {
simple = self.simple.overrideAttrs (_old: {
pname = "customCargoTargetDirectory";
doInstallCargoArtifacts = false;
CARGO_TARGET_DIR = "some/nested/custom-cargo-dir";
Expand Down
2 changes: 0 additions & 2 deletions checks/mkDummySrcTests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ let
filteredInput = lib.cleanSourceWith {
src = input;
filter = path: type:
let baseName = builtins.baseNameOf path;
in
type == "directory" || lib.any (s: lib.hasPrefix s (builtins.baseNameOf path)) [
"Cargo"
"config"
Expand Down
1 change: 0 additions & 1 deletion checks/nextest.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{ cargo-nextest
, cargoNextest
, lib
, linkFarmFromDrvs
, runCommand
}:

Expand Down
2 changes: 1 addition & 1 deletion examples/cross-musl/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
};
};

outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
outputs = { nixpkgs, crane, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = import nixpkgs {
Expand Down
5 changes: 2 additions & 3 deletions examples/cross-rust-overlay/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
};
};

outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
outputs = { nixpkgs, crane, flake-utils, rust-overlay, ... }:
# NB: temporarily skip aarch64-darwin since QEMU can't build there on nixpkgs-unstable
flake-utils.lib.eachSystem [ "aarch64-linux" "i686-linux" "x86_64-darwin" "x86_64-linux" ] (localSystem:
let
Expand Down Expand Up @@ -48,8 +48,7 @@
# Normally you can stick this function into its own file and pass
# its path to `callPackage`.
crateExpression =
{ lib
, openssl
{ openssl
, pkg-config
, qemu
, stdenv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
flake-utils.follows = "crane/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, crane }: flake-utils.lib.eachDefaultSystem
outputs = { flake-utils, crane, ... }: flake-utils.lib.eachDefaultSystem
(system: {
packages.dummy = crane.lib.${system}.mkDummySrc {
src = ./.;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
flake-utils.follows = "crane/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, crane }: flake-utils.lib.eachDefaultSystem
outputs = { self, flake-utils, crane, ... }: flake-utils.lib.eachDefaultSystem
(system: {
packages.dummy = crane.lib.${system}.mkDummySrc {
src = self;
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
};
};

outputs = inputs@{ self, nixpkgs, flake-utils, rust-overlay, ... }:
outputs = { nixpkgs, flake-utils, rust-overlay, ... }:
let
mkLib = pkgs: import ./lib {
inherit (pkgs) lib newScope;
Expand All @@ -27,7 +27,7 @@
{
inherit mkLib;

overlays.default = final: prev: { };
overlays.default = _final: _prev: { };

templates = rec {
alt-registry = {
Expand Down
3 changes: 1 addition & 2 deletions lib/cargoDoc.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{ mkCargoDerivation
}:

{ cargoArtifacts
, cargoDocExtraArgs ? "--no-deps"
{ cargoDocExtraArgs ? "--no-deps"
, cargoExtraArgs ? ""
, ...
}@origArgs:
Expand Down
1 change: 0 additions & 1 deletion lib/cargoNextest.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ cargo-nextest
, lib
, linkFarmFromDrvs
, mkCargoDerivation
, runCommand
}:
Expand Down
6 changes: 2 additions & 4 deletions lib/cargoTarpaulin.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{ buildDepsOnly
, mkCargoDerivation
{ mkCargoDerivation
, cargo-tarpaulin
}:

{ cargoArtifacts
, cargoExtraArgs ? ""
{ cargoExtraArgs ? ""
, cargoTarpaulinExtraArgs ? "--skip-clean --out Xml --output-dir $out"
, ...
}@origArgs:
Expand Down
4 changes: 2 additions & 2 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let
inherit (self) callPackage;
in
{
appendCrateRegistries = input: self.overrideScope' (final: prev: {
appendCrateRegistries = input: self.overrideScope' (_final: prev: {
crateRegistries = prev.crateRegistries // (lib.foldl (a: b: a // b) { } input);
});

Expand Down Expand Up @@ -43,7 +43,7 @@ in
mkCargoDerivation = callPackage ./mkCargoDerivation.nix { };
mkDummySrc = callPackage ./mkDummySrc.nix { };

overrideToolchain = toolchain: self.overrideScope' (final: prev: {
overrideToolchain = toolchain: self.overrideScope' (_final: _prev: {
cargo = toolchain;
clippy = toolchain;
rustc = toolchain;
Expand Down
1 change: 0 additions & 1 deletion lib/downloadCargoPackage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{ name
, version
, checksum
, source
, ...
}@args:
let
Expand Down
2 changes: 1 addition & 1 deletion lib/downloadCargoPackageFromGit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
, rev
, ref ? null
, allRefs ? ref == null
}@args:
}:
let
maybeRef = lib.optionalAttrs (ref != null) { inherit ref; };
repo = builtins.fetchGit (maybeRef // {
Expand Down
1 change: 0 additions & 1 deletion lib/findCargoFiles.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ let
inherit (lib)
flatten
groupBy
lists
mapAttrs
mapAttrsToList;

Expand Down
3 changes: 2 additions & 1 deletion lib/mkCargoDerivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
, crateNameFromCargoToml
, inheritCargoArtifactsHook
, installCargoArtifactsHook
, lib
, stdenv
, vendorCargoDeps
, zstd
Expand Down Expand Up @@ -38,6 +37,8 @@ let
];
in
chosenStdenv.mkDerivation (cleanedArgs // {
inherit cargoArtifacts;

pname = "${args.pname or crateName.pname}${args.pnameSuffix or ""}";
version = args.version or crateName.version;

Expand Down
3 changes: 1 addition & 2 deletions lib/mkDummySrc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ let
inherit (builtins)
dirOf
concatStringsSep
hasAttr
pathExists;
hasAttr;

inherit (lib)
optionalString
Expand Down
3 changes: 1 addition & 2 deletions lib/registryFromGitIndex.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{ lib
, registryFromDownloadUrl
{ registryFromDownloadUrl
}:

{ indexUrl
Expand Down
2 changes: 1 addition & 1 deletion lib/vendorGitDeps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ let
(attrNames sources);

configReplaceGitSources = mapAttrsToList
(hashedId: ps:
(_hashedId: ps:
let
p = head ps;
extractAttr = attr:
Expand Down

0 comments on commit 2ce1a33

Please sign in to comment.