Skip to content

Commit

Permalink
Stop bootstrapping rnix-lsp as it is unmaintained
Browse files Browse the repository at this point in the history
Also allow the possibility of not including buildInputs in a shell, since it's now
possible to not require anything from nixpkgs.
  • Loading branch information
sd234678 committed Mar 20, 2024
1 parent 59c7951 commit bd41462
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .last-exported-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Last exported commit from parent repo: 6a71c253c9cb6e804e58f923f3c294ea164c99e1
Last exported commit from parent repo: 67d50f90e5ca6530f4799983c0b11245988a6c3c
2 changes: 1 addition & 1 deletion nix-bootstrap.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 2.0
-- see: https://github.com/sol/hpack

name: nix-bootstrap
version: 1.5.5.3
version: 1.5.6.0
author: gchquser
maintainer: [email protected]
copyright: Crown Copyright
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
name: nix-bootstrap
version: 1.5.5.3
version: 1.5.6.0
author: gchquser
maintainer: [email protected]
copyright: Crown Copyright
Expand Down
2 changes: 1 addition & 1 deletion src/Bootstrap/Data/Bootstrappable/NixShell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ nixShellFor RunConfig {rcUseFlakes} projectType preCommitHooksConfig nixPreCommi
. fmap EIdent
nixpkgsBuildInputsFor :: ProjectType -> [Expr]
nixpkgsBuildInputsFor =
sortBy compareBuildInputs . (([nix|rnix-lsp|] : [[nix|niv|] | not rcUseFlakes]) <>) . \case
sortBy compareBuildInputs . (([[nix|niv|] | not rcUseFlakes]) <>) . \case
Minimal -> []
Elm elmOptions ->
[ [nix|elmPackages.elm|],
Expand Down
32 changes: 18 additions & 14 deletions src/Bootstrap/Nix/Expr/BuildInputs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,33 @@ data BuildInputSpec projectType = BuildInputSpec
buildInputsBindings :: HasProjectSuperType t => BuildInputSpec t -> [Binding]
buildInputsBindings spec@BuildInputSpec {bisNativeNixpkgsPackages} =
catMaybes
[ Just $ [nixproperty|buildInputs|] |= foldr (|++) buildInputGroupExpr1 otherBuildInputGroupExprs,
[ case buildInputGroupExprs of
[] -> Nothing
[buildInputGroupExpr1] ->
Just $ [nixproperty|buildInputs|] |= buildInputGroupExpr1
(buildInputGroupExpr1 : otherBuildInputGroupExprs) ->
Just $ [nixproperty|buildInputs|] |= foldr (|++) buildInputGroupExpr1 otherBuildInputGroupExprs,
if null bisNativeNixpkgsPackages
then Nothing
else Just $ [nixproperty|nativeBuildInputs|] |= groupToExpr (BIGNativeNixpkgsInputs bisNativeNixpkgsPackages)
]
where
buildInputGroups :: NonEmpty BuildInputGroup
buildInputGroups :: [BuildInputGroup]
buildInputGroups = buildInputGroupsFor spec
groupPackageSets :: Bool
groupPackageSets = length buildInputGroups > 1
groupToExpr :: BuildInputGroup -> Expr
groupToExpr g = (if groupPackageSets && requiresGrouping g then EGrouping else id) (toNixExpr g)
buildInputGroupExpr1 :: Expr
otherBuildInputGroupExprs :: [Expr]
(buildInputGroupExpr1 :| otherBuildInputGroupExprs) = groupToExpr <$> buildInputGroups
buildInputGroupExprs :: [Expr]
buildInputGroupExprs = groupToExpr <$> buildInputGroups

buildInputGroupsFor :: HasProjectSuperType t => BuildInputSpec t -> NonEmpty BuildInputGroup
buildInputGroupsFor :: HasProjectSuperType t => BuildInputSpec t -> [BuildInputGroup]
buildInputGroupsFor BuildInputSpec {..} =
BIGNixpkgs bisNixpkgsPackages
:| catMaybes
[ if unPreCommitHooksConfig bisPreCommitHooksConfig then Just BIGPreCommitHooks else Nothing,
if projectSuperType bisProjectType == PSTPython then Just BIGPythonPackages else Nothing,
case bisOtherPackages of
[] -> Nothing
otherPackages -> Just $ BIGOther otherPackages
]
catMaybes
[ if null bisNixpkgsPackages then Nothing else Just (BIGNixpkgs bisNixpkgsPackages),
if unPreCommitHooksConfig bisPreCommitHooksConfig then Just BIGPreCommitHooks else Nothing,
if projectSuperType bisProjectType == PSTPython then Just BIGPythonPackages else Nothing,
case bisOtherPackages of
[] -> Nothing
otherPackages -> Just $ BIGOther otherPackages
]
21 changes: 5 additions & 16 deletions test/Bootstrap/Data/Bootstrappable/FlakeNixSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ spec = describe "flake.nix rendering" do
in {
devShell = self.devShells.${system}.default;
devShells.default = nixpkgs.mkShell {
buildInputs = with nixpkgs; [
awscli2
nodejs
rnix-lsp
];
buildInputs = with nixpkgs; [awscli2 nodejs];
};
});
}
Expand Down Expand Up @@ -88,7 +84,6 @@ spec = describe "flake.nix rendering" do
awscli2
nodePackages.pnpm
nodejs
rnix-lsp
];
};
});
Expand Down Expand Up @@ -137,13 +132,7 @@ spec = describe "flake.nix rendering" do
checks.pre-commit-check = preCommitHooks.pureHooks;
devShell = self.devShells.${system}.default;
devShells.default = nixpkgs.mkShell {
buildInputs =
preCommitHooks.tools
++ (with nixpkgs; [
awscli2
nodejs
rnix-lsp
]);
buildInputs = preCommitHooks.tools ++ (with nixpkgs; [awscli2 nodejs]);
inherit (preCommitHooks.allHooks) shellHook;
};
# runChecks is a hack required to allow checks to run on a single system
Expand Down Expand Up @@ -198,7 +187,7 @@ spec = describe "flake.nix rendering" do
checks.pre-commit-check = preCommitHooks.pureHooks;
devShell = self.devShells.${system}.default;
devShells.default = nixpkgs.mkShell {
buildInputs = preCommitHooks.tools ++ (with nixpkgs; [go rnix-lsp]);
buildInputs = preCommitHooks.tools ++ (with nixpkgs; [go]);
inherit (preCommitHooks.allHooks) shellHook;
};
defaultPackage = self.packages.${system}.default;
Expand Down Expand Up @@ -246,7 +235,7 @@ spec = describe "flake.nix rendering" do
in {
devShell = self.devShells.${system}.default;
devShells.default = nixpkgs.mkShell {
buildInputs = [pythonPackages] ++ (with nixpkgs; [rnix-lsp]);
buildInputs = [pythonPackages];
};
});
}
Expand Down Expand Up @@ -294,7 +283,7 @@ spec = describe "flake.nix rendering" do
checks.pre-commit-check = preCommitHooks.pureHooks;
devShell = self.devShells.${system}.default;
devShells.default = nixpkgs.mkShell {
buildInputs = preCommitHooks.tools ++ (with nixpkgs; [libiconv rnix-lsp]);
buildInputs = preCommitHooks.tools ++ (with nixpkgs; [libiconv]);
nativeBuildInputs = with nixpkgs; [
cargo
rust-analyzer
Expand Down
22 changes: 5 additions & 17 deletions test/Bootstrap/Data/Bootstrappable/NixShellSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ in
awscli2
niv
nodejs
rnix-lsp
];
}
|]
Expand All @@ -55,7 +54,6 @@ in
niv
nodePackages.pnpm
nodejs
rnix-lsp
];
}
|]
Expand All @@ -74,13 +72,7 @@ in
};
in
nixpkgs.mkShell {
buildInputs =
preCommitHooks.tools
++ (with nixpkgs; [
go
niv
rnix-lsp
]);
buildInputs = preCommitHooks.tools ++ (with nixpkgs; [go niv]);
inherit (preCommitHooks.allHooks) shellHook;
}
|]
Expand Down Expand Up @@ -110,7 +102,7 @@ in
haskellEnv = haskellPackages.ghcWithPackages (pkgs: with pkgs; [cabal-install haskell-language-server]);
in
nixpkgs.mkShell {
buildInputs = [haskellEnv] ++ (with nixpkgs; [niv rnix-lsp]);
buildInputs = [haskellEnv] ++ (with nixpkgs; [niv]);
}
|]
)
Expand All @@ -131,7 +123,7 @@ in
};
in
nixpkgs.mkShell {
buildInputs = [pythonPackages] ++ (with nixpkgs; [niv rnix-lsp]);
buildInputs = [pythonPackages] ++ (with nixpkgs; [niv]);
}
|]
)
Expand All @@ -157,7 +149,7 @@ in
};
in
nixpkgs.mkShell {
buildInputs = preCommitHooks.tools ++ [pythonPackages] ++ (with nixpkgs; [niv rnix-lsp]);
buildInputs = preCommitHooks.tools ++ [pythonPackages] ++ (with nixpkgs; [niv]);
inherit (preCommitHooks.allHooks) shellHook;
}
|]
Expand All @@ -172,11 +164,7 @@ in
nixpkgs = import sources.nixpkgs {};
in
nixpkgs.mkShell {
buildInputs = with nixpkgs; [
libiconv
niv
rnix-lsp
];
buildInputs = with nixpkgs; [libiconv niv];
nativeBuildInputs = with nixpkgs; [
cargo
rust-analyzer
Expand Down
6 changes: 2 additions & 4 deletions test/Bootstrap/Nix/Expr/MkShellSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,24 @@ spec = do
it "gives no shell hook when one isn't needed" do
mkShell (BuildInputSpec [] [] (PreCommitHooksConfig False) PSTMinimal [])
`shouldBe` [nix|nixpkgs.mkShell {
buildInputs = with nixpkgs; [];
}|]
it "gives a proper shell hook for projects with pre-commit hooks" do
mkShell (BuildInputSpec [] [] (PreCommitHooksConfig True) PSTMinimal [])
`shouldBe` [nix|nixpkgs.mkShell {
buildInputs = preCommitHooks.tools ++ (with nixpkgs; []);
buildInputs = preCommitHooks.tools;
inherit (preCommitHooks.allHooks) shellHook;
}|]
it "gives a proper shell hook for Rust projects" do
mkShell (BuildInputSpec [] [] (PreCommitHooksConfig False) PSTRust [])
`shouldBe` [nix|nixpkgs.mkShell {
buildInputs = with nixpkgs; [];
shellHook = ''
export RUST_SRC_PATH=${nixpkgs.rustPlatform.rustLibSrc}
'';
}|]
it "gives a proper shell hook for Rust projects with pre-commit hooks" do
mkShell (BuildInputSpec [] [] (PreCommitHooksConfig True) PSTRust [])
`shouldBe` [nix|nixpkgs.mkShell {
buildInputs = preCommitHooks.tools ++ (with nixpkgs; []);
buildInputs = preCommitHooks.tools;
shellHook = ''
export RUST_SRC_PATH=${nixpkgs.rustPlatform.rustLibSrc}
${preCommitHooks.allHooks.shellHook}
Expand Down

0 comments on commit bd41462

Please sign in to comment.