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
123
124
125
126
use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[command(
name = "nixy",
about = "Homebrew-style wrapper for Nix using flake.nix"
)]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
/// Install a package from nixpkgs
#[command(alias = "add")]
Install(InstallArgs),
/// Uninstall a package
#[command(alias = "remove")]
Uninstall(UninstallArgs),
/// List packages in flake.nix
#[command(alias = "ls")]
List,
/// Search for packages
Search {
/// Search query
query: String,
},
/// Upgrade all inputs or specific ones
Upgrade(UpgradeArgs),
/// 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
SelfUpgrade(SelfUpgradeArgs),
/// Show nixy version
Version,
}
#[derive(Args)]
pub struct InstallArgs {
/// Package name to install
pub package: Option<String>,
/// Install from a flake (registry name or URL)
#[arg(long)]
pub from: Option<String>,
/// Install from local nix file
#[arg(long, short)]
pub file: Option<PathBuf>,
}
#[derive(Args)]
pub struct UpgradeArgs {
/// Specific inputs to upgrade (if empty, upgrades all)
pub inputs: Vec<String>,
}
#[derive(Args)]
pub struct SyncArgs {}
#[derive(Args)]
pub struct UninstallArgs {
/// Package name to uninstall
pub package: String,
}
#[derive(Args)]
pub struct ProfileArgs {
#[command(subcommand)]
pub command: Option<ProfileCommands>,
}
#[derive(Subcommand)]
pub enum ProfileCommands {
/// Switch to a different profile
#[command(alias = "use")]
Switch {
/// Profile name
name: String,
/// Create the profile if it doesn't exist
#[arg(short)]
c: bool,
},
/// List all profiles
#[command(alias = "ls")]
List,
/// Delete a profile
#[command(alias = "rm")]
Delete {
/// Profile name to delete
name: String,
/// Force deletion without confirmation
#[arg(long)]
force: bool,
},
}
#[derive(Args)]
pub struct SelfUpgradeArgs {
/// Force reinstall even if already at latest version
#[arg(long, short)]
pub force: bool,
}