1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
use clap::{Args, Parser, Subcommand};
#[derive(Parser)]
#[command(
name = "nixy",
about = "Homebrew-style wrapper for Nix using flake.nix",
disable_help_subcommand = true
)]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
/// Install a package from nixpkgs [alias: add]
#[command(alias = "add")]
Install(InstallArgs),
/// Uninstall a package [alias: remove]
#[command(alias = "remove")]
Uninstall(UninstallArgs),
/// List packages in flake.nix [alias: ls]
#[command(alias = "ls")]
List,
/// Search for packages
Search {
/// Search query
query: String,
},
/// Update packages and flake inputs
Update(UpdateArgs),
/// Build environment from flake.nix and create symlink
Sync(SyncArgs),
/// Output shell config (for eval in rc files)
Config {
/// Shell type (bash, zsh, fish)
shell: String,
},
/// Profile management commands
Profile(ProfileArgs),
/// Upgrade nixy to the latest version
Upgrade(UpgradeArgs),
/// Show path to package source file in Nix store
File(FileArgs),
/// Print dynamic completion candidates (used by shell completions)
#[command(hide = true)]
Completions(CompletionsArgs),
}
#[derive(Args)]
pub struct InstallArgs {
/// Package name to install
pub package: Option<String>,
/// Only install on specific platform(s). Valid values: darwin, macos, linux,
/// x86_64-darwin, aarch64-darwin, x86_64-linux, aarch64-linux
#[arg(long, short = 'p')]
pub platform: Vec<String>,
}
#[derive(Args)]
pub struct UpdateArgs {
/// Specific packages or inputs to update
pub inputs: Vec<String>,
/// Update all packages and inputs
#[arg(long, conflicts_with = "inputs")]
pub all: bool,
}
#[derive(Args)]
pub struct SyncArgs {}
#[derive(Args)]
pub struct UninstallArgs {
/// Package name to uninstall
pub package: String,
}
#[derive(Args)]
pub struct ProfileArgs {
/// Profile name
pub name: Option<String>,
/// Create the profile if it doesn't exist
#[arg(short, conflicts_with = "d")]
pub c: bool,
/// Delete the specified profile
#[arg(short, conflicts_with = "c")]
pub d: bool,
}
#[derive(Args)]
pub struct UpgradeArgs {
/// Force reinstall even if already at latest version
#[arg(long, short)]
pub force: bool,
}
#[derive(Args)]
pub struct FileArgs {
/// Package name
pub package: String,
}
#[derive(Args)]
pub struct CompletionsArgs {
/// What to complete (e.g. installed, profiles)
pub kind: String,
}