nixpkgs/pkgs/tools/networking/ifwifi/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

51 lines
1.6 KiB
Nix

{ lib, stdenv, fetchFromGitHub, rustPlatform, makeWrapper, networkmanager, iw, Security }:
rustPlatform.buildRustPackage rec {
pname = "ifwifi";
version = "1.2.0";
src = fetchFromGitHub {
owner = "araujobsd";
repo = "ifwifi";
rev = version;
sha256 = "sha256-DPMCwyKqGJrav0wASBky9bS1bvJ3xaGsDzsk1bKaH1U=";
};
cargoHash = "sha256-TL7ZsRbpRdYymJHuoCUCqe/U3Vacb9mtKFh85IOl+PA=";
nativeBuildInputs = [ makeWrapper ];
buildInputs = lib.optional stdenv.hostPlatform.isDarwin Security;
postInstall = ''
wrapProgram "$out/bin/ifwifi" \
--prefix PATH : "${lib.makeBinPath (
# `ifwifi` runtime dep
[ networkmanager ]
# `wifiscanner` crate's runtime deps
++ (lib.optional stdenv.hostPlatform.isLinux iw)
# ++ (lib.optional stdenv.hostPlatform.isDarwin airport) # airport isn't packaged
)}"
'';
doCheck = true;
meta = with lib; {
description = "Simple wrapper over nmcli using wifiscanner made in rust";
mainProgram = "ifwifi";
longDescription = ''
In the author's words:
I felt bothered because I never remember the long and tedious command
line to setup my wifi interface. So, I wanted to develop something
using rust to simplify the usage of nmcli, and I met the wifiscanner
project that gave me almost everything I wanted to create this tool.
'';
homepage = "https://github.com/araujobsd/ifwifi";
license = with licenses; [ bsd2 ];
maintainers = with maintainers; [ blaggacao ];
# networkmanager doesn't work on darwin
# even though the `wifiscanner` crate would work
platforms = with platforms; linux; # ++ darwin;
};
}