Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encourage NixOS configuration, nix-shell and discourage nix-env #514

Merged
merged 3 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 122 additions & 17 deletions frontend/src/Page/Packages.elm
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ viewResultItem nixosChannels channel showInstallDetails show item =
optionals (Just item.source.attr_name == show)
[ div [ trapClick ]
(div []
(item.source.longDescription
|> Maybe.map (\desc -> [ p [] [ text desc ] ])
|> Maybe.withDefault []
)
:: div []
[ h4 []
[ text "How to install "
, em [] [ text item.source.attr_name ]
Expand All @@ -515,31 +520,45 @@ viewResultItem nixosChannels channel showInstallDetails show item =
Maybe.withDefault
[ li
[ classList
[ ( "active", List.member showInstallDetails [ Search.Unset, Search.FromNixOS, Search.FromFlake ] )
[ ( "active", List.member showInstallDetails [ Search.Unset, Search.ViaNixOS, Search.FromFlake ] )
, ( "pull-right", True )
]
]
[ a
[ href "#"
, Search.onClickStop <|
SearchMsg <|
Search.ShowInstallDetails Search.FromNixOS
Search.ShowInstallDetails Search.ViaNixOS
]
[ text "On NixOS" ]
[ text "NixOS Configuration" ]
]
, li
[ classList
[ ( "active", showInstallDetails == Search.FromNixpkgs )
[ ( "active", showInstallDetails == Search.ViaNixShell )
, ( "pull-right", True )
]
]
[ a
[ href "#"
, Search.onClickStop <|
SearchMsg <|
Search.ShowInstallDetails Search.FromNixpkgs
Search.ShowInstallDetails Search.ViaNixShell
]
[ text "On non-NixOS" ]
[ text "nix-shell" ]
]
, li
[ classList
[ ( "active", showInstallDetails == Search.ViaNixEnv )
, ( "pull-right", True )
]
]
[ a
[ href "#"
, Search.onClickStop <|
SearchMsg <|
Search.ShowInstallDetails Search.ViaNixEnv
]
[ text "nix-env" ]
]
]
<|
Expand Down Expand Up @@ -568,25 +587,116 @@ viewResultItem nixosChannels channel showInstallDetails show item =
Maybe.withDefault
[ div
[ classList
[ ( "active", showInstallDetails == Search.FromNixpkgs )
[ ( "tab-pane", True )
, ( "active", showInstallDetails == Search.ViaNixEnv )
]
]
[ p []
[ strong [] [ text "Warning:" ]
, text """
Using nix-env permanently modifies a
local profile of installed packages.
This must be cleaned up, updated and
maintained by the user, in the same
way as a traditional package
manager. Using nix-shell or a NixOS
configuration is recommended
instead.
"""
]
]
, div
[ classList
[ ( "active", showInstallDetails == Search.ViaNixEnv )
]
, class "tab-pane"
]
[ p []
[ strong [] [ text "On NixOS:" ] ]
]
, div
[ classList
[ ( "active", showInstallDetails == Search.ViaNixEnv )
]
, class "tab-pane"
, id "package-details-nixpkgs"
]
[ pre [ class "code-block" ]
[ pre [ class "code-block shell-command" ]
[ text "nix-env -iA nixos."
, strong [] [ text item.source.attr_name ]
]
]
, div [] [ p [] [] ]
, div
[ classList
[ ( "active", showInstallDetails == Search.ViaNixEnv )
]
, class "tab-pane"
]
[ p []
[ strong [] [ text "On Non NixOS:" ] ]
]
, div
[ classList
[ ( "active", showInstallDetails == Search.ViaNixEnv )
]
, class "tab-pane"
, id "package-details-nixpkgs"
]
[ pre [ class "code-block shell-command" ]
[ text "nix-env -iA nixpkgs."
, strong [] [ text item.source.attr_name ]
]
]
, div
[ classList
[ ( "tab-pane", True )
, ( "active", List.member showInstallDetails [ Search.Unset, Search.FromNixOS, Search.FromFlake ] )
, ( "active", showInstallDetails == Search.ViaNixShell )
]
]
[ p []
[ text """
A nix-shell will temporarily modify
your $PATH environment variable.
This can be used to try a piece of
software before deciding to
permanently install it.
"""
]
]
, div
[ classList
[ ( "active", showInstallDetails == Search.ViaNixShell )
]
, class "tab-pane"
, id "package-details-nixpkgs"
]
[ pre [ class "code-block shell-command" ]
[ text "nix-shell -p "
, strong [] [ text item.source.attr_name ]
]
]
, div
[ classList
[ ( "tab-pane", True )
, ( "active", List.member showInstallDetails [ Search.Unset, Search.ViaNixOS, Search.FromFlake ] )
]
]
[ p []
[ text "Add the following Nix code to your NixOS Configuration, usually located in "
, strong [] [ text "/etc/nixos/configuration.nix" ]
]
]
, div
[ classList
[ ( "tab-pane", True )
, ( "active", List.member showInstallDetails [ Search.Unset, Search.ViaNixOS, Search.FromFlake ] )
]
]
[ pre [ class "code-block" ]
[ text <| "nix-env -iA nixos."
[ text <| " environment.systemPackages = [\n pkgs."
, strong [] [ text item.source.attr_name ]
, text <| " \n ];"
]
]
]
Expand All @@ -599,7 +709,7 @@ viewResultItem nixosChannels channel showInstallDetails show item =
, ( "active", True )
]
]
[ pre [ class "code-block" ]
[ pre [ class "code-block shell-command" ]
[ text "nix build "
, strong [] [ text url ]
, text "#"
Expand All @@ -611,12 +721,7 @@ viewResultItem nixosChannels channel showInstallDetails show item =
<|
Maybe.map Tuple.first item.source.flakeUrl
]
:: ((item.source.longDescription
|> Maybe.map (\desc -> [ p [] [ text desc ] ])
|> Maybe.withDefault []
)
++ maintainersAndPlatforms
)
:: maintainersAndPlatforms
)
]

Expand Down
5 changes: 3 additions & 2 deletions frontend/src/Search.elm
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,9 @@ type Msg a b


type Details
= FromNixpkgs
| FromNixOS
= ViaNixShell
| ViaNixOS
| ViaNixEnv
| FromFlake
| Unset

Expand Down
20 changes: 10 additions & 10 deletions frontend/src/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
background: #333;
color: #fff;
margin: 0;

&:before {
content: "$ "
}
Comment on lines -10 to -12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of having this in a :before is that the dollar sign is not copied when you select the whole block

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pre-existing css is the strangest I've ever seen. What's up with all the nth-child selectors? Positional as opposed to named css? That's just an awful idea.
So I can't blame Matthew for not restoring this functionality for nix-env. He had to remove the $ for the declarative installation methods, which are more important anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, it's awful. There's no need to stick to that pattern though: adding a shell-commands class outside the hierarchy would be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with elm enough to accomplish this. If you could make a PR that does it to my fork, I'll merge it and it'll be done. But I think the scope of this PR will then have been increased more than it needs to be.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! I pushed to your branch directly.

}


Expand Down Expand Up @@ -67,6 +63,10 @@ body {
cursor: text;
}

.shell-command:before {
content: "$ ";
}

#content {
padding-bottom: 4rem;
}
Expand Down Expand Up @@ -388,8 +388,13 @@ header .navbar.navbar-static-top {
margin: 2em 0 1em 1em;
text-align: left;

// how to install a package
// long description of a package
& > :nth-child(1) {
margin-top: 1em;
}

// how to install a package
& > :nth-child(2) {

h4 {
font-size: 1.2em;
Expand Down Expand Up @@ -417,11 +422,6 @@ header .navbar.navbar-static-top {

}

// long description of a package
& > :nth-child(2) {
margin-top: 1em;
}

// maintainers and platforms
& > :nth-child(3) {
margin-top: 1em;
Expand Down