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

Fix/wrong colors status labels & nix buildingShell devShell not allowing to build cartero due to missing dependencies #84

Merged
merged 3 commits into from
Oct 22, 2024
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
23 changes: 21 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,32 @@
LD_LIBRARY_PATH = lib.makeLibraryPath [
gtk4
libadwaita
glib
];

buildInputs = [
rustc
nativeBuildInputs = [
meson
ninja
cargo
rustc
rustfmt
pkg-config
blueprint-compiler
desktop-file-utils
gtk4
shared-mime-info
glib
wrapGAppsHook
hicolor-icon-theme
Copy link
Owner

Choose a reason for hiding this comment

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

I have a somehow unrelated question here.

What's the difference between default.nix and flake.nix? I remember that some dependencies were added to default.nix back in #44.

Learning Nix is still on my to do list, but are there some cases where default.nix is preferred over flake.nix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well yeah it all depends on how you structure the nix implementation for your project, for cartero i tried to do it in a way similar to how i've seen in anothers projects ppl already did it, which is, using a flake.nix to create dev shells (environments where you get automatically all the dependencies for building your project), and exposing packages (so ppl can do in their terminal per example, nix run github:danirod/cartero and it will run cartero by downloading everything in one command (this actually works btw)) so the thing here is that im adding those dependencies aswell for the dev shell, so i get an environment to be able to build cartero manually by using meson setup build -Dprofile=development myself

The thing is that for some reason i had forgotten to add these aswell here before when i packaged this for nix? idk lmao but in any case this will do the trick

so in resume for this project

  1. we've flake.nix to expose dev shells and packages (the package is the one that ppl merges in their environment.systemPackages by using inputs.cartero.packages.x86_64-linux.default), in the dev shell i wanna get an environment where i get a development build of cartero and the dependencies to manually build it
  2. we've default.nix which is the cartero derivation, which defines all the steps to build cartero to nix. It's probably not as explicit to say which commands it should run because pkgs.rustPlatform already got some abstractions around that, and also the meson hook (runHook meson line) which automates it a little bit.

Copy link
Contributor Author

@AlphaTechnolog AlphaTechnolog Oct 21, 2024

Choose a reason for hiding this comment

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

There're also others ways to packages nix projects without flakes (which is starting to be the preferred way) over nix channels, which is the older way... you may wonder why nix flakes over nix channels? nix channels requires user intervention for managing them, they'll define an upstream url and the user should manage them manually to switch to nixpkgs unstable or nixpkgs stable when the project requires it, with nix flakes you can define as the project maintainer which one to use, and which one your nix dependencies (third party projects) should follow, either it's unstable, stable, or even a nixpkgs fork

The legacy packaging usually used to look somehow like this

  • shell.nix:
{ pkgs ? import <nixpkgs> {}, ... }: pkgs.mkShell {
  buildInputs = [...];
}

Inside mkShell it's basically the same as i did in the flake.nix, in fact i could make a legacy dev shell and then import it in my flake.nix so we get support for both legacy dev shells, and flakes based shells. Note that the ? import <nixpkgs> {} expr, means that the pkgs parameter, if not passed by no one, it will default to the result of importing nixpkgs (and around <> means from a nix channel)... this is similar to the expression i did in flake.nix that looks like this pkgs = import nixpkgs {inherit system overlays;}

  • default.nix: Which is basically the same as i did in the default.nix we've, but probably by tinkering a little bit around that pkgs parameter because we would have to use nix channels to import them.

Copy link
Owner

Choose a reason for hiding this comment

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

I am totally taking notes of this.

(I think that if I just get an Ethernet cable and a wired connection I could skip the "can't learn NixOS because can't setup the wifi on the NixOS I've just installed" phase)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danirod how's that? have you got a weird wifi driver or something like that? i remember having such issue with a wifi dongle which didn't support in some older kernels, but in fact if you just enable networking.networkmanager.enable = true when installing nixos, it will add wifi support for the system when installing it, that ofc if the kernel has the drivers for wifi support on your system. If using calamares i am not sure tho, but you could follow the manual installation instructions via /mnt/etc/nixos/configuration.nix file and the nixos-install cli tool inside the livecd.

Copy link
Owner

Choose a reason for hiding this comment

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

I still don't know the reason. Naively I think that using NetworkManager is cheating, because then the network config would not be declarative. (It's fair to say that a declarative wifi config could be unsafe if not done properly, specially because PSK keys.) However, it seems to ignore me when I rebuild the system. Further research is still needed.

];

buildInputs = [
gtksourceview5
pango
gdk-pixbuf
openssl_3_3
graphene
libadwaita
];
};

Expand Down
8 changes: 8 additions & 0 deletions src/widgets/response_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ impl ResponsePanel {
500..=599 => "error",
_ => "neutral",
};

// This will stop classes with higher priorities to override the currently
// needed one by resetting the classes, see [this](https://github.com/danirod/cartero/issues/83).
let possible_classes = vec!["success", "warning", "error", "neutral"];
for css_class in possible_classes {
imp.status_code.remove_css_class(css_class);
}

imp.status_code.add_css_class(&status_color);

let duration = format!("{} s", resp.seconds());
Expand Down