Skip to content

Commit

Permalink
add rule nix_unfree
Browse files Browse the repository at this point in the history
  • Loading branch information
KiaraGrouwstra committed Feb 24, 2024
1 parent 74f3244 commit 16d838b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ The following rules are enabled by default on specific platforms only:
* `dnf_no_such_command` – fixes mistyped DNF commands;
* `nixos_cmd_not_found` – installs apps on NixOS;
* `nix_shell` – re-runs your command using `nix run`;
* `nix_unfree` – re-runs your command with `NIXPKGS_ALLOW_UNFREE=1`;
* `pacman` – installs app with `pacman` if it is not installed (uses `yay`, `pikaur` or `yaourt` if available);
* `pacman_invalid_option` – replaces lowercase `pacman` options with uppercase.
* `pacman_not_found` – fixes package name with `pacman`, `yay`, `pikaur` or `yaourt`.
Expand Down
21 changes: 21 additions & 0 deletions thefuck/rules/nix_unfree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from thefuck.specific.nix import nix_available
import subprocess

enabled_by_default = nix_available

# Set the priority just ahead of `fix_file` rule, which can generate low quality matches due
# to the sheer amount of paths in the nix store.
priority = 999


def match(command):
return (
"NIXPKGS_ALLOW_UNFREE=1" in command.output
)


def get_new_command(command):
commands = [
'NIXPKGS_ALLOW_UNFREE=1 {}'.format(command.script)
]
return commands

0 comments on commit 16d838b

Please sign in to comment.